O
Otto Moehrbach
Excel 2002, WinXP
I've shortened the code to show my problem. The object here is to move some
sheets to the far left. The code is:
Option Explicit
Public ExemptList() As String
Sub Macro1
Call BuildExemptArray
Call MoveExemptSheets
End Sub
Sub BuildExemptArray()
ReDim ExemptList(1 To 3)
ExemptList(1) = "AddrList"
ExemptList(2) = "ChkList"
ExemptList(3) = "ClientShtsList"
End Sub
Sub MoveExemptSheets()
Dim c As Long
For c = UBound(ExemptList) To LBound(ExemptList) Step -1 '**Problem
line
Sheets(ExemptList(c)).Move Before:=Sheets(1)
Next
End Sub
This code is straightforward and I've used it before, but now I am getting a
"Subscript out of range'" error on the "For c =" line.
I can see I might get this error with the subsequent line if one of the
array sheets didn't exist or is hidden, but I can't see a reason for this
error with this line.
Thanks for your help. Otto
I've shortened the code to show my problem. The object here is to move some
sheets to the far left. The code is:
Option Explicit
Public ExemptList() As String
Sub Macro1
Call BuildExemptArray
Call MoveExemptSheets
End Sub
Sub BuildExemptArray()
ReDim ExemptList(1 To 3)
ExemptList(1) = "AddrList"
ExemptList(2) = "ChkList"
ExemptList(3) = "ClientShtsList"
End Sub
Sub MoveExemptSheets()
Dim c As Long
For c = UBound(ExemptList) To LBound(ExemptList) Step -1 '**Problem
line
Sheets(ExemptList(c)).Move Before:=Sheets(1)
Next
End Sub
This code is straightforward and I've used it before, but now I am getting a
"Subscript out of range'" error on the "For c =" line.
I can see I might get this error with the subsequent line if one of the
array sheets didn't exist or is hidden, but I can't see a reason for this
error with this line.
Thanks for your help. Otto
.