Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

I now prefer to use a Sub to call this function and react accordingly like so:

Public Sub WorksheetCreate(sName As String)
Dim sExists As Boolean
sExists = Evaluate("ISREF('" & sName & "'!A1)")
If sExists = False Then
With ActiveWorkbook
    .Sheets.Add(After:=.Sheets(.Sheets.Count)).Name = sName
End With
End If
End Sub

Test:

Sub Test()
WorksheetCreate ("Test")
End Sub
Function WorksheetExists(sName As String) As Boolean
    WorksheetExists = Evaluate("ISREF('" & sName & "'!A1)")
End Function
Sub test()
 SheetExists = WorksheetExists("PivotTable")
 MsgBox SheetExists
End Sub
  • No labels