View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
J.E. McGimpsey J.E. McGimpsey is offline
external usenet poster
 
Posts: 493
Default Subscript our of range when activating a worksheet

one way:

Dim wkSht As Worksheet
On Error Resume Next
Set wkSht = dataWB.Sheets(Invoice_Sheet)
On Error GoTo 0
If Not wkSht Is Nothing Then
'Do Stuff
Else
MsgBox "Sheet " & Invoice_Sheet & " does not exist."
End If


In article ,
"cb" wrote:

Hi all,
I try to activate a worksheet that macro can't find. The
code is like this: dataWB.Sheets(Invoice_Sheet).Activate
Because the sheet name does not exist, users got a run-
time error '9', Subscript out of range. Is there a way to
replace this runtime error with a warning message using
msgbox?
Thanks,
cb