I needed to alternate between columns A and B when writing to a bunch of rows in VBA. I created a variable, lStartCol, that I intended to alternate between zero and one and use in an Offset property.
rCell.Offset(lStartCol, 0).Value = “Some number”
I thought that was pretty clever, but I discovered that the first row may not always be the same. The entry in the first row has to start in column A, so that wouldn’t work. By the way, rCell is the iterative component in a For Each loop. I ended up with this
I put this at the end of the loop. lStartCol starts at zero (because I initialize there before the loop), so the first iteration stays in column A. Then it subtracts one, takes the absolute value and lStartCol become 1. Sure, I could have
lStartCol = 0
lStartCol = 1
but that would be a cop out.