Hello, I am extremely new to VBA. I am trying to do something very simple and I am running into this error. In my Excel Workbook, there are several sheets. The ones of interest are named "CAR Daily Report Macro" and "CAR Daily Report." I am setting up a macro to copy and paste data from another workbook (this part of the code is working) and I want it to delete the top 5 rows on the new sheet, which is where I am getting the error code. I (think) I changed the active sheet, so I do not know what is happening. here is my code:
Private Sub CAR_Daily_Report_Click()
'Settings to make Macro load faster
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
'Create new sheet and copy information from exported sheet
Sheets.Add.Name = "CAR Daily Report"
Workbooks("02. CARs_5. All.xlsx").Worksheets("02. CARs_5. All").Range("A1:G3000").Copy _
Workbooks("Main Macro Workbook.xlsm").Worksheets("CAR Daily Report").Range("A1")
'Change the active sheet
Worksheets("CAR Daily Report").Activate
'Attempt at deleting top rows
Rows("1:5").Select
Selection.Delete Shift:=xlUp
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
End Sub
Private Sub CAR_Daily_Report_Click()
'Settings to make Macro load faster
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
ActiveSheet.DisplayPageBreaks = False
'Create new sheet and copy information from exported sheet
Sheets.Add.Name = "CAR Daily Report"
Workbooks("02. CARs_5. All.xlsx").Worksheets("02. CARs_5. All").Range("A1:G3000").Copy _
Workbooks("Main Macro Workbook.xlsm").Worksheets("CAR Daily Report").Range("A1")
'Change the active sheet
Worksheets("CAR Daily Report").Activate
'Attempt at deleting top rows
Rows("1:5").Select
Selection.Delete Shift:=xlUp
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
ActiveSheet.DisplayPageBreaks = True
End Sub