Thread: Macro Help
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Macro Help

Sub fillin()
lr = Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To lr
If Cells(i, "b") = "" Then Cells(i, "b") _
= Cells(i - 1, "b") + 1
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"James" wrote in message
...
I have a set a data that comes to me about 3 or 4 times a week. The data
looks like this
A B C ----Columns
12 1001 0
35 2.5
28 5.8
30 8
29 1035 0
56 3
42 6.2
22 2021 0
11 2.2
60 9.2

I am just concerned with column B and column C. A new sample ID starts
every time when there is a 0 in column C. I need something that will
increase the number in column B by 1. So for the first set I would want
column B to go from 1001, 1002, 1003, 1004. But when we hit the new sample
ID
1035, I need the numbers to go 1035, 1036 etc... Below is what I would
like
it to end up as:

A B C ----Columns
12 1001 0
35 1002 2.5
28 1003 5.8
30 1004 8
29 1035 0
56 1036 3
42 1037 6.2
22 2021 0
11 2022 2.2
60 2023 9.2

Thanks for any help.