Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How to use a variable as a sheets code name

Dr. Schwartz -- maybe try something like this ...


Sub DeleteSheets()

Dim WSCodeNum As Integer

' Suspend error handling
On Error Resume Next

' Suspend alerts
Application.DisplayAlerts = False

For WSCodeNum = 1 To 32

Worksheets("P" & WSCodeNum).Delete

Next

' Reinstate alerts
Application.DisplayAlerts = True

End Sub


--

Hope it Helps,

- Rodney POWELL
Microsoft MVP - Excel

Beyond Technology
Spring, Texas USA
www.BeyondTechnology.com




"Dr.Schwartz" wrote in message ...
I want to delete x number of sheets. How can I assign the sheet code name to
a variable to make this piece of code work:

'Removing any existing report sheets
Dim WSCodeNum As Integer, WSCodeName
For WSCodeNum = 1 To 32
WSCodeName = "P" & WSCodeNum
Application.DisplayAlerts = False
WSCodeName.Delete
On Error Resume Next
Application.DisplayAlerts = True
Next

By the error I get I'm guessing the WSCodeName should be declared differently?

Thanks
The Doctor
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
can i link a variable cost code with a variable sum I need help!! Excel Discussion (Misc queries) 0 August 1st 08 11:40 AM
add new sheets in a workbook with new sheets being a variable [email protected] Excel Discussion (Misc queries) 1 April 11th 06 08:38 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
variable code?? Paul Excel Discussion (Misc queries) 1 April 5th 05 06:37 PM
Variable in a VB Code Michael Kintner Excel Programming 1 January 5th 04 02:29 PM


All times are GMT +1. The time now is 05:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"