View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 1,327
Default Does worksheet exist

Function SheetXist(ShName As String) As Boolean
On Error Resume Next
SheetXist = Len(Sheets(ShName).Name)
End Function

Sub Test()
MsgBox SheetXist("Sheet1")
MsgBox SheetXist("Sheet4501")
End Sub

HTH. Best wishes Harald

"Robert S" skrev i melding
...
I'm looking for a way to get a boolean result if a given
worksheet name already exists - for example if workbook
text.xls contains sheet1, sheet2, and sheet3, then if I
pass a variable containing the worksheet 'sheet4', I would
get a false value returned. Any help would be appreciated.

Thanks