I paste data into an Excel worksheet. I and am trying to create a macro that will clean up the data.
Some days the data I need starts on line 20 and some days it might start on 21 or 22. The only constant is that the data I need to start from is always labeled "1" in column A.
I cobbled together some code. (My base code is from the record macro action. I made adjustments based on google searches.)
Dim row_num As Integer
Sheets("AMD").Select
ActiveSheet.Paste
'initialize variable
row_num = Sheets("CopyPaste").Range("F2").Value
Sheets("AMD").Range(Cells(1), Cells(row_num)).Select
Selection.Delete Shift:=xlUp
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select
I get
Run-time error '1004': Method '_Default' of object 'Range' failed.
Debug sends me to:
Sheets("AMD").Range(Cells(1), Cells(row_num)).Select
The integer from 'CopyPaste'!F2 is the number of rows I need to delete.