LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 125
Default Need help with deleteing sheets using VBA

Ok the object of this code is that once it is done running that It will
cumulatively Select all sheets in a workbook that are NOT named "STable" or
"SChart" much in the same way as if you were to manually hold down the Cntrl
button and start clicking (selecting) multiple sheets with in a workbook

Why doesn't this work ?

here is my code:

Sub Test()
Dim y as integer
Dim t as interger

For y = 1 To SheetCount
If Not Sheets(y).Name = "STable" Then
If Not Sheets(y).Name = "SChart" Then
t = t + 1
ReDim Preserve SheetsToDel(t)
SheetsToDel(t) = Sheets(y).Name
End If
End If
Next y

For y = 1 To UBound(SheetsToDel())
If y = UBound(SheetsToDel()) Then
StrA = Chr(34) + SheetsToDel(y) + Chr(34)
Else
StrA = Chr(34) + SheetsToDel(y) + Chr(34) + ","
End If
StrB = StrB + StrA
Next y
Sheets(Array(StrB)).Select
End Sub

This doesn't work and yet if I just try this line of code:

Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select

It works. My StrB is the same thing as manually typing in the string the
the line above so what gives any thoughts ??


 
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
deleteing objects Debi Excel Discussion (Misc queries) 2 January 16th 07 06:25 PM
deleteing documents Gildee New Users to Excel 1 November 8th 06 09:31 AM
Deleteing koba Excel Discussion (Misc queries) 2 November 25th 05 04:11 AM
deleteing duplicates syssupspe Excel Discussion (Misc queries) 2 April 28th 05 12:15 AM
Deleteing Rows Michael Vaughan Excel Programming 2 September 20th 04 09:53 PM


All times are GMT +1. The time now is 07:23 AM.

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

About Us

"It's about Microsoft Excel"