Autofill

T

T De Villiers

a8=8
b8 = 4
c8 = a8 +b8

a8: 500 and b8:b500 are populated with nos, however with the code belo

the autofill occurs only from c8 to c16, pretty sure its the las
line.help is much appreciated

Sub test()
Dim iLastRow As Long
Dim iLastCol As Long
Dim i As Long, j As Long

iLastCol = Cells(8, Columns.Count).End(xlToLeft).Column
For j = 1 To iLastCol
If Cells(8, j).HasFormula Then
iLastRow = Cells(Rows.Count, j).End(xlUp).Row
Cells(8, j).AutoFill Cells(8, j).Resize(iLastRow)
End If
Next j

End Su
 
D

Dave Peterson

Maybe you should use column B instead of the lastcol to get the last row?

iLastRow = Cells(Rows.Count, "B").End(xlUp).Row

And since you're starting in row 8, don't you want:

Cells(8, j).AutoFill Cells(8, j).Resize(iLastRow-8+1)
 

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

Similar Threads


Top