Autofill to the last empty cell in a range

  • Thread starter Thread starter Jim
  • Start date Start date
J

Jim

I have a list that looks like this:

10010 11221 102.00
102.00
102.00
10011 11247 103.50
103.50
103.50


The list goes on for thousands of rows. The columns are A, B and C.
I am trying unsucessfully to create a macro to autofill the first two
columns until the numbers change. In other words, 10010 would stop at
the last empty cell above 10011. It would repeat this all down the
page.

I am currently trying to count up from the bottom of the page...but I
don't know the code to loop the formula.

Thanks
 
Sub fillcolumns()

RowCount = 1
StartRow = RowCount
Do While Range("C" & RowCount) <> ""
If Range("A" & (RowCount + 1)) <> "" Or _
Range("C" & (RowCount + 1)) = "" Then

Range("A" & StartRow & ":B" & StartRow).Copy _
Destination:=Range("A" & StartRow & ":B" & RowCount)

StartRow = RowCount + 1
End If

RowCount = RowCount + 1
Loop
End Sub
 
See John Walkenbach's clever, non vba, method...
http://spreadsheetpage.com/index.php/tip/duplicate_repeated_entries_in_a_list/
--
Jim Cone
Portland, Oregon USA



"Jim" <[email protected]>
wrote in message
I have a list that looks like this:

10010 11221 102.00
102.00
102.00
10011 11247 103.50
103.50
103.50

The list goes on for thousands of rows. The columns are A, B and C.
I am trying unsucessfully to create a macro to autofill the first two
columns until the numbers change. In other words, 10010 would stop at
the last empty cell above 10011. It would repeat this all down the
page.
I am currently trying to count up from the bottom of the page...but I
don't know the code to loop the formula.
Thanks
 
Back
Top