View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default selecting all worksheets to the right of specified worksheet

Hi,

Try this

This line
Sheets(1).Activate
ensures sheets are not already grouped so may not be necessary

Sub SelectSheets()
Dim ws As Worksheet
Sheets(1).Activate
For Each ws In ActiveWorkbook.Sheets
If ws.Index Worksheets("DT").Index Then
ws.Select False
End If
Next ws
End Sub


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"PVANS" wrote:

Good morning

I hope someone can help me with this:
I am trying to create a "clean master file" using a macro that the user can
run at the end of each week/month.

In order for this to happen - I need to select all the client worksheets and
delete specific ranges and rows within them. In terms of deleting the ranges
- I can do that.

However, I am unsure how to select all worksheets to the right of the
specific header worksheet called "DT" - I do not want to select the
worksheets to the left of this, as they contain invoice and master report
sheets; and of course, the number of client sheets will grow each month so I
can't simply record the macro as it will be outdated as soon as a new client
is added.

Is there a method I can use to select all worksheets that are to the right
of a specific sheet (the "DT" sheet)?

Thank you for any ideas and help given

Regards,

Paul