Hi all,
I have the following code:
However, it is failing on autofilling the formula down to the last cell. If I use LR as the last row identifier than it works, but as there are 7 rows more data on the ("Imported Fuel Usage Data") it autofills the forumla down to far.
Also, ideally I would like to fill the formula down to the last row but one, but can't figure out how to set the variable for such a function.
Any help would be great.
Thanks in advance
I have the following code:
Code:
Public Sub copydata()
Dim LR As Long
Dim TR As Long
LR = Sheets("Imported Fuel Usage Data").Range("A" & Rows.Count).End(xlUp).Row
TR = Sheets("FData").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Imported Fuel Usage Data").Range("A8:B" & LR).Copy Destination:=Sheets("fdata").Range("A" & 1)
Sheets("fdata").Select
Sheets("fdata").Range("C1").Formula = "=((B1+B2)/2)*(A2-A1)"
Sheets("fdata").Range("C1").AutoFill Destination:=Range("C1:C" & TR), Type:=xlFillDefault
End Sub
However, it is failing on autofilling the formula down to the last cell. If I use LR as the last row identifier than it works, but as there are 7 rows more data on the ("Imported Fuel Usage Data") it autofills the forumla down to far.
Also, ideally I would like to fill the formula down to the last row but one, but can't figure out how to set the variable for such a function.
Any help would be great.
Thanks in advance
Last edited: