View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_4_] Bob Phillips[_4_] is offline
external usenet poster
 
Posts: 834
Default selecting all worksheets to the right of specified worksheet

Dim SelectedSheets As Variant
Dim CurrIdx As Long
Dim NextSheet As Long
Dim i As Long

With ActiveWorkbook

CurrIdx = .Worksheets("DT").Index
ReDim SelectedSheets(1 To .Worksheets.Count)
For i = CurrIdx + 1 To .Worksheets.Count

NextSheet = NextSheet + 1
SelectedSheets(NextSheet) = .Worksheets(i).Name
Next i

ReDim Preserve SelectedSheets(1 To NextSheet)

.Worksheets(SelectedSheets).Select
End With


--

HTH

Bob

"PVANS" wrote in message
...
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