plasteredric
03-02-2018, 08:54 AM
I have the following code
Sub DAILY_FORMULA_AUTOFILL()
Dim Found As Range
With ActiveSheet ' do everything on the active sheet from here on
Set Found = .Range("A:A").Find("***X", lookat:=xlWhole)
If Found Is Nothing Then
MsgBox "Table Start Point Not Found", 0, "Check Error"
Exit Sub
End If
FirstDataRow = Found.Row + 1
LastRow = .Cells(Rows.Count, "G").End(xlUp).Row ' This finds the last cell with data in it in column G on active sheet
Range("DAILY_FORMULA_RANGE_A").Copy Range("Y416:Y" & LastRow)
End With
End Sub
This works as is, but I was trying to use the 'found' and 'firstdatarow' rather than Y416:Y as a precaution, should i add additional rows / columns in the future. The range of Cells i am autofilling down is Y416:AB416 .
Any ideas for how i can do this? also from what i've read where i have 'LastRow' this should be the bottom rightmost cell of the destination range, in the example this would be AB545. Will having 'LastRow' cause any issues?
Thanks
Sub DAILY_FORMULA_AUTOFILL()
Dim Found As Range
With ActiveSheet ' do everything on the active sheet from here on
Set Found = .Range("A:A").Find("***X", lookat:=xlWhole)
If Found Is Nothing Then
MsgBox "Table Start Point Not Found", 0, "Check Error"
Exit Sub
End If
FirstDataRow = Found.Row + 1
LastRow = .Cells(Rows.Count, "G").End(xlUp).Row ' This finds the last cell with data in it in column G on active sheet
Range("DAILY_FORMULA_RANGE_A").Copy Range("Y416:Y" & LastRow)
End With
End Sub
This works as is, but I was trying to use the 'found' and 'firstdatarow' rather than Y416:Y as a precaution, should i add additional rows / columns in the future. The range of Cells i am autofilling down is Y416:AB416 .
Any ideas for how i can do this? also from what i've read where i have 'LastRow' this should be the bottom rightmost cell of the destination range, in the example this would be AB545. Will having 'LastRow' cause any issues?
Thanks