S
sean.mcinnis
I am using Excel 2003 I am trying to test is a sheet exist and if not
create the sheet.
I have search the and have found and edited the following in a moduel.
I have been testing this but it is always returning False. Unless
filter_by = "Sheet1"
Function SheetExists(SheetName As String) As Boolean
On Error Resume Next
SheetExists = CBool(Len(ThisWorkbook.Worksheets(SheetName).Name))
End Function
Sub test()
Dim filter_by As String
filter_by = "test"
If SheetExists(filter_by) = False Then
Worksheets.Add.Name = filter_by
Else
' do something else
End If
End Sub
create the sheet.
I have search the and have found and edited the following in a moduel.
I have been testing this but it is always returning False. Unless
filter_by = "Sheet1"
Function SheetExists(SheetName As String) As Boolean
On Error Resume Next
SheetExists = CBool(Len(ThisWorkbook.Worksheets(SheetName).Name))
End Function
Sub test()
Dim filter_by As String
filter_by = "test"
If SheetExists(filter_by) = False Then
Worksheets.Add.Name = filter_by
Else
' do something else
End If
End Sub