View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Selecting Specific Sheets

This should be close...

Dim lng As Long

Sheets(2).Select
For lng = 2 To Sheets.Count - 1
Sheets(lng).Select False
Next lng

--
HTH...

Jim Thomlinson


" wrote:

I am trying to have all but two sheets selected out of a varying
number of possible sheets. The two that I don't want selected are
Sheet1 and the very last one (SheetX for example).

So far I have used this code below, but it only gets me half way there
(doesn't select the first sheet, but still has the last one selected
with the rest of the group).

Dim shCount As Integer

ThisWorkbook.Worksheets(2).Select
For shCount = 3 To ThisWorkbook.Worksheets.Count
Worksheets(shCount).Select (False)
Next shCount
For Each ws In Worksheets
Next ws

Any other ideas?