How do I resolve vba error 1004 when trying to autofill using a variable for dynamic range?

Alley, Ann 0 Reputation points
2024-05-22T20:00:40.64+00:00

I get error 1004 on this line of Excel vba code and don't know how to resolve.

Selection.AutoFill Destination:=Range("R2:R" & lastRow)

Dim wb As Workbook

Dim ws As Worksheet

Set wb = ActiveWorkbook

Set ws = Sheets("Milestones")

wb.Activate

ws.Select



Dim lastRow As Long

lastRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Excel | For business | Windows
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.