-
Add consecutive numbers
Hi,
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
Thanks
-
Knowledge Base Approver
The King of Overkill!
VBAX Master
Do you need code to do it? You could just put into B2
=IF(ISNUMBER(C2),B1+1,"")
And fill down
If you really want VBA..[vba] With Range("C2", Cells(Rows.Count, "C").End(xlUp)).Offset(0, -1)
.Formula = "=ROW()" & IIf(.Row > 1, "-" & .Row - 1, "")
.Value = .Value
End With[/vba]
Matt
-
Enter 1 in the first cell, hold down Control and drag the fill button.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules