Error 424 Object Required trying to delete worksheet

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
I'm using this to save a copy of the existing workbook, open it and then I'm trying to delete specific sheets in the newly created workbook but I'm getting an error 424, object required on the line that deletes the worksheet. Anyone help me understand why?

VBA Code:
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\Test Save.xlsm"

SavedWB = ThisWorkbook.Path & "\Test Save.xlsm"

Application.Workbooks.Open SavedWB

SavedWB.Worksheets("SETUP").Delete
SavedWB.Worksheets("HISTORICAL").Delete
SavedWB.Worksheets("FULLDATA").Delete
SavedWB.Worksheets("STAFF").Delete
SavedWB.Worksheets("SUMMARY").Activate
SavedWB.Save

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Your variable, SavedWB is a string, not a workbook. You need to set it to the correct variable type.
VBA Code:
Dim SavedWB As Workbook
Set SavedWB = Workbooks.Open(ThisWorkbook.Path & "\Test Save.xlsm")
 
Upvote 0
Solution

Forum statistics

Threads
1,215,620
Messages
6,125,876
Members
449,268
Latest member
sGraham24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top