View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default Test worksheet name

Hi Petr

Try this one

With ActiveSheet
If Not .Name = "Revenue" Or .Name = "SF Revenue" _
Or .Name = "Rbn" Then
MsgBox "Correct sheet was not chosen!", vbCritical
End If
End With


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Petr" wrote in message om...
Hallo,
I would need to test whether the active sheet has one of the name from
several possibilities.

I tried the simple code below, but it is ending with error.

Sub worksheet_name_test()

Dim wks As Worksheet
If Not wks.Name = "Revenue" Or wks.Name = "SF Revenue" Or wks.Name =
"Rbn" Then
MsgBox "Correct sheet was not chosen!", vbCritical
End If
End Sub


Thank you in advance for any suggestions.

Petr Duzbaba