View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John[_113_] John[_113_] is offline
external usenet poster
 
Posts: 8
Default Can't seem to find the error with this code

It works fine on my machine...
Make sure you are using the line
Dim x

....and that Worbook is a typo (should be spelt Workbook)

Rgds
J



"matelot" wrote in message
...
Hi,
I don't know why I can't pass thru this code. I know it's fairly straight
forward but everytime I run it's always giving the error "Object required"
even if my active workbook contains the sheetname "mydata". Can you tell
me
what's wrong with this code. All I am trying to do is to check if a
sheetname
exists.

On Error Resume Next
Set x = ActiveWorbook.Sheets("mydata")
If Err = 0 Then
MsgBox "Passed "
Else
MsgBox ActiveWorkbook.Name & " - " & Error(Err)
MsgBox "Sheet does not exist"
End If

Thanks