copying formula to a randow row

O

Ole

I want to use the autofill to copy a formula
by using a macro. When I register the macro VBA suggests ie
Selection.AutoFill Destination:=Range("C1:C8")

but I don't want to predetermine how long the range is to be, because it can
vary from 100 to 25000 rows, and I want the copy function to stop at the
last cell that has a value to the left.

Thanks Oystein (Norway)
 
F

Frank Kabel

Hi
try something like

lastrow = Activesheet.Cells(Rows.Count,"B").End(xlUp).Row
Selection.AutoFill Destination:=Range("C1:C" & lastrow)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top