Autofill code

I'm writing code in sheet 1 that does an autofill in sheet 2, but it does not seem to recognize the command. It simply ignores the line and proceeds to the next line of code.
'ActiveSheet.Selection.AutoFill  _
 Destination:=ActiveSheet.Range("A9:A" & pg_2_dates),  _ 
 'Type:=xlFillDefault

Sheets("WAProInt (2)").Selection.AutoFill  _ 
Destination:=Sheets("WAProint (2)").Range("A9:A18"),  _ 
Type:=xlFillDefault
As you can see, I've added references to the sheet name in the second line of code, but it still doesn't work. any ideas?
Vishesh's picture

Use Activate

Sheets("WAProInt (2)").Activate
 
Sheets("WAProInt (2)").Selection.AutoFill  _
Destination:=Sheets("WAProint (2)").Range("A9:A18"),  _
Type:=xlFillDefault
Vishesh's picture

Instead of selection use

Instead of selection use range as you are in different sheet than the target sheet.
Sheets("WAProInt (2)").Range("A8").AutoFill  _
 Destination:=Sheets("WAProint (2)").Range("A9:A18"),  _
 Type:=xlFillDefault