how to check if there is a worksheet with a given name

I

ILiya

I need to check:
1. if there is a worksheet with a given name
2. find a number (index) of worksheet with that name

Thanks
 
T

Tushar Mehta

What have you tried so far? Where are you stuck?

In XL VBA check the help for the Worksheets collection and the Item
property of the collection.

To find the number of a worksheet, hopefully, what you mean is the Index
property of the worksheet object. Look that up in XL VBA help.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Multi-disciplinary business expertise
+ Technology skills
= Optimal solution to your business problem
Recipient Microsoft MVP award 2000-2005
 
G

George Nicholson

Untested aircode:

Function FindSheetName(strName as string) as integer
Dim i as integer
FindSheetName = 0
For i = 1 to Worksheets.count
If Worksheets(i).Name = strName Then
MsgBox "Sheet # " & i & " matches your specifications."
FindSheetName = 1
Exit Function
End If
Next i
MsgBox "No sheets match your specifications."
End Function
 

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