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 VBA code for tab exists

Hi Marc

There are many ways but I like to use a function for it

Function SheetExists(SName As String, _
Optional ByVal WB As Workbook) As Boolean
'Chip Pearson
On Error Resume Next
If WB Is Nothing Then Set WB = ThisWorkbook
SheetExists = CBool(Len(WB.Sheets(SName).Name))
End Function


You can call the function in Your macro like this

If SheetExists("Sheet1") = False Then
'not exist
Else
'exist
End If




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"MFINE" wrote in message ...
Looking for code or a statement that comfirms if a tab in excel exists,
similar to FileExists method. Any suggestions?

Thanks

Marc