Find a worksheet

L

Luis

Hello.
I need to check if a certain worksheet exists in a
workbook.
Is there something like a find worksheet ?

Thanks
Luis
 
C

CoRrRan

Hello.
I need to check if a certain worksheet exists in a
workbook.
Is there something like a find worksheet ?

Thanks
Luis

This should do the trick:
********************************************
Sub FindSheet()

Dim oSheet As Object

For Each oSheet In ActiveWorkbook.Sheets
If oSheet.Name = "Sheet3" Then
MsgBox "Found the sheet!", vbOKOnly
End If
Next

End Sub
********************************************
Good luck,

CoRrRan
 
F

Frank Kabel

Hi
try something like
dim wks as worksheet
on error resume next
set wks = worksheets("your_name")
on error goto 0
if wks is nothing then
msgbox "worksheet does not exist"
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top