duncanjackson
New Member
- Joined
- Nov 7, 2019
- Messages
- 2
Hi
I have done lots of Google searches and found nothing on this. Normally I can find an answer on Google, or force the code to do what I want by trying a different method.
I have a VBA problem that is driving me nuts.
I'm using End(xlUp) to find my last row.
When I hover over Last row in the code it correctly identifies the last row as 10687
I then autofill formula's from my 2nd row to Last row...
... And for some reason it fills to Row 210678
Here is my bit of code:
Does anyone know why the Macro correctly identifies the last row I want to fill to, but then merrily careers past it?
I've also tried the following and the same happens with this method too:
Many thanks in advance for anyone who can help!
I have done lots of Google searches and found nothing on this. Normally I can find an answer on Google, or force the code to do what I want by trying a different method.
I have a VBA problem that is driving me nuts.
I'm using End(xlUp) to find my last row.
When I hover over Last row in the code it correctly identifies the last row as 10687
I then autofill formula's from my 2nd row to Last row...
... And for some reason it fills to Row 210678
Here is my bit of code:
Code:
'Copy formulas down With Sheets("HMRC")
LastRow = Range("G" & Rows.Count).End(xlUp).Row
End With
Range("A2:E2").Select
Selection.AutoFill Destination:=Range("A2:E2" & LastRow)
Range("L2:Y2").Select
Selection.AutoFill Destination:=Range("L2:Y2" & LastRow)
Does anyone know why the Macro correctly identifies the last row I want to fill to, but then merrily careers past it?
I've also tried the following and the same happens with this method too:
Code:
'Declare variable
'
Dim LR As Long
'
'Copy formulas down
Range("A2:E2").Select
LR = Sheets("HMRC").Range("G1").CurrentRegion.Rows.Count
Selection.AutoFill Destination:=Range("A2:E2" & LR)
Range("L2:U2").Select
Selection.AutoFill Destination:=Range("L2:U2" & LR)
Many thanks in advance for anyone who can help!