Autofill to Last Row but Miss Some Rows?
let me know if this does not work for you
Dim lastRow As Long
Dim startRow as Long
Dim strData as String
startRow=2
lastRow = Range("A65536").End(xlUp).row
strData=Range(7,8)
For i=startRow to lastRow
If cells(i+5,4)<"" then cells(i,8)=strData 'if D7 has something H2=H7
Next
--
-John
Please rate when your question is answered to help us and others know what
is helpful.
"Dave" wrote:
Hi Guys,
I'm trying to write in to a macro the ability to Autofill a column from a
cell (H7) to LastRow as you can see below, but miss out rows that have no
value in Column D.
E.g.
If
LastRow is 20
D7 has value? Yes. Fill Row.
D8 has value? Yes. Fill Row.
D9 has value? No. Skip Row.
D10 has value? Yes. Fill Row.........
Code:
Dim lastRow As Long
lastRow = Range("A65536").End(xlUp).row
Range("H7:H7").Select
Selection.AutoFill Destination:=Range("H2:H" & lastRow)
Can anyone help with this?
Thanks
Dave
|