Hi, I have the following code that is not working like I want it to. When the active cell is before column Q then columns A2-C2 copy and fill in columns R-T. If the active cell is after Q then cells A2-Q2 copy and fill down in column S to AH. What I want is from A2 to Q2 to fill down to the last row in the table. Any tips on how to better my code? The macros needs to work on several workbooks each with their own table but the column names are the same in each table.
Sub Macro3_Autofill()
'Fills down to last row in table
Dim LastRow As Range
Dim Selection1 As Range
Dim Selection2 As Range
Set LastRow = ActiveSheet.UsedRange.SpecialCells(xlLastCell)
Set Selection1 = ActiveSheet.Range("A2:Q2")
Set Selection2 = ActiveSheet.Range("A2:Q2", LastRow)
Selection1.AutoFill Destination:=Selection2, Type:=xlFillDefault
End Sub
Sub Macro3_Autofill()
'Fills down to last row in table
Dim LastRow As Range
Dim Selection1 As Range
Dim Selection2 As Range
Set LastRow = ActiveSheet.UsedRange.SpecialCells(xlLastCell)
Set Selection1 = ActiveSheet.Range("A2:Q2")
Set Selection2 = ActiveSheet.Range("A2:Q2", LastRow)
Selection1.AutoFill Destination:=Selection2, Type:=xlFillDefault
End Sub