Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
can i link a variable cost code with a variable sum | Excel Discussion (Misc queries) | |||
add new sheets in a workbook with new sheets being a variable | Excel Discussion (Misc queries) | |||
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? | Excel Worksheet Functions | |||
variable code?? | Excel Discussion (Misc queries) | |||
Variable in a VB Code | Excel Programming |