Delete selected worksheets

C

Casey

Hello Everybody,

I have a macro created below that only delete selected worksheets in a
workbook. But I keep recieve error massage . May I know where goes wrong ??
Can anyone help ??

Thanks in advance !!!

Application.DisplayAlerts = False
Sheets("Table 1").Delete
Sheets("Table 2").Delete
Sheets("Table 3").Delete
Sheets("Table 4").Delete
Sheets(Activesheets).Delete
Application.DisplayAlerts = True
 
M

Mike H

There is something wrong with the code

Sheets(Activesheets).Delete

should be

ActiveSheet.Delete

And remember you cannot delete every sheet in a workbook.

Mike
 
C

Casey

Hi Mike,

Thanks for your reply & help.

I do still recieve error message " Subscript out of range"
There are many other more worksheets which i do not want to delete..

Casey
 
M

Mike H

Casey

Sheets(Activesheets).Delete

Will give that error message

use

ActiveSheet.Delete

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top