For building zig zag grids # Invert every nth ( here 10) values me.inputCell if int(me.inputCell.offset(0,-1)/10)%2 == 0 else me.inputCell*-1