View Full Version : Add consecutive numbers

06-20-2007, 06:11 AM

Sorry my mind has gone completely blank... I have this:

<Attached spreadsheet> (have added red what i want the code to do)

Basically, if there is a number in Column "C", I want the code to insert a number (starting at 1) in Column "B". Then goto the next cell, if there is a value there, put a "2" in the next one, until there is no value in column C. I would much appreciate peoples help as my brain has died :)


06-20-2007, 06:22 AM
Do you need code to do it? You could just put into B2
And fill down

If you really want VBA.. With Range("C2", Cells(Rows.Count, "C").End(xlUp)).Offset(0, -1)
.Formula = "=ROW()" & IIf(.Row > 1, "-" & .Row - 1, "")
.Value = .Value
End With

06-20-2007, 07:09 AM
Enter 1 in the first cell, hold down Control and drag the fill button.

06-20-2007, 07:12 AM
Yes thank you. A very simple task on its own in excel but its part of a much larger routine. Thank you though, it is much appreciated :)