View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
[email protected] EagleOne@discussions.microsoft.com is offline
external usenet poster
 
Posts: 391
Default Worksheet Sort - but all sheets in array do not exist

2003

Thanks to Chuck Pearson I have the following VBA code:

Sub SortWS3()

Dim SortOrder As Variant
Dim Ndx As Long
SortOrder = Array("CSheet", "ASheet", "BSheet")
For Ndx = UBound(SortOrder) To LBound(SortOrder) Step -1
Worksheets(SortOrder(Ndx)).Move befo=Worksheets(1)
Next Ndx

End Sub

The challenge is that each workbook may not have all of the sheets.

What I need is a way for the array to SKIP the non-existant sheets OR
an alternative approach.

Any thoughts are appreciated

Thanks EagleOne