VBA error code?

samilynn

Board Regular
Joined
Jun 24, 2003
Messages
171
Office Version
  1. 2016
Platform
  1. Windows
I am running a macro which moves all worksheets in the active workbook to new workbooks in a specified folder.
However, lately I started getting this error message. Do you know what it means, and what I can do about it?
Thanks

An error has occurred. Error number =1004. Error description = Method 'SaveAs' of object '_Workbook failed.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi samilynn,

The error simply means that the code can't do the SaveAs as requested. From what you have described I suspect it is because the code is trying to move all the sheets from the workbook, and this is illegal. A workbook must have at least one sheet. One way around this problem is to add a new blank sheet to the workbook:

Application.Worksheets.Add

I hope this helps.

Damon
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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