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

I think you have the request backwards... As per the OP..."The two that I
don't want selected are Sheet1 and the very last one"... Those are the only
two sheets your code selects.
--
HTH...

Jim Thomlinson


" wrote:

I suspect a one-line would do the job. Try this:

Sheets(Array(Sheets(1).Name, Sheets(Worksheets.Count).Name)).Select

The definition of "first" and "very last" can get odd in Excel. This
code picks the left-most and right-most tabs within the workbook.
HTH

/ Tyla /



On Feb 28, 11:12 am, 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?