PC Review


Reply
Thread Tools Rate Thread

Delete selected worksheets

 
 
Casey
Guest
Posts: n/a
 
      14th Nov 2008
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


 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      14th Nov 2008
Thre's nothing wrong with the code. What is the error message?

"Casey" wrote:

> 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
>
>

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      14th Nov 2008
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

"Mike H" wrote:

> Thre's nothing wrong with the code. What is the error message?
>
> "Casey" wrote:
>
> > 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
> >
> >

 
Reply With Quote
 
Casey
Guest
Posts: n/a
 
      14th Nov 2008
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

"Mike H" wrote:

> 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
>
> "Mike H" wrote:
>
> > Thre's nothing wrong with the code. What is the error message?
> >
> > "Casey" wrote:
> >
> > > 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
> > >
> > >

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      14th Nov 2008
Casey

Sheets(Activesheets).Delete

Will give that error message

use

ActiveSheet.Delete

Mike

"Casey" wrote:

> 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
>
> "Mike H" wrote:
>
> > 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
> >
> > "Mike H" wrote:
> >
> > > Thre's nothing wrong with the code. What is the error message?
> > >
> > > "Casey" wrote:
> > >
> > > > 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
> > > >
> > > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Selected Worksheets Macro Indianagreg Microsoft Excel Programming 3 31st Dec 2008 02:20 PM
Looping through selected worksheets and delete a range (e.g., A2:D15) jsaynavong@gmail.com Microsoft Excel Programming 1 10th Oct 2007 01:41 AM
Delete rows at the same time from selected worksheets =?Utf-8?B?Rmlsbw==?= Microsoft Excel Programming 3 5th May 2007 02:41 PM
Re: When I highlight a sentence to delete, Word won't let me. I have to backspace. How can I deleted selected text with my delete key? Bill Foley Microsoft Word Document Management 1 4th Feb 2004 11:06 PM
sum across worksheets selected mark v Microsoft Excel Worksheet Functions 1 15th Oct 2003 12:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:14 PM.