Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete an Excel page 1

Status
Not open for further replies.

MrMajik

IS-IT--Management
Joined
Apr 2, 2002
Messages
267
I am using VisualBasic and have the code delete a worksheet called Temp when done with it. Here is how I am doing it:

Sheets("Temp").Select
ActiveWindow.SelectedSheets.Delete

This always asks the user if they want to delete it. The answer is always Yes. Is there a way to delete a worksheet without the user getting involved?

Thank you.
 
Dreamboat; That's a good BINGO! Lets give a star for that :-)

Thank you very much.

MrMajik
 
Just as an addendum you can often also use a similar logic to speed up your code. If your code would involve a lot of jumping about between ranges or spreadsheets, then this can impact speed.

Application.ScreenUpdating = False

at the beginning of your code, and

Application.ScreenUpdating = True

at the end is similar to the old commands you may remember of Echo On and Echo Off. It will stop the sceren showing what is going on, and only at the end of the code will it finally update the screen.

Regards
Ken...............

 
KenWright; You must be reading my mind! I was wondering if your suggestion was possible.

Thank you for sharing. :-)

MrMajik
 
MrMajik
Just another little addition for information. Code can be speeded up by not selecting objects unless absolutely necessary. In the case you have here
Code:
Worksheets("Test").Delete
will do the same job without selecting the sheet then referring to it throught the active window object.

;-)

If a man says something and there are no women there to hear him, is he still wrong? [ponder]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top