Function SheetExists(sName As String, _
Optional oWb As Workbook) As Boolean
‘Returns true if sheet exists in the specified workbook.
‘If no workbook supplied, the activeworkbook is used.
If oWb Is Nothing Then
Set oWb = ActiveWorkbook
End If
On Error Resume Next
SheetExists = CBool(Not oWb.Sheets(sName) Is Nothing)
On Error GoTo 0
End Function
SheetExists does not work, always returns False in VBA from Office 2003. It may work if the current worksheet perhaps?
Also comment lines begin with L and therefore will not compile.
Should start with ‘ character instead.
Paste the code into a regular code module (not a sheet module), and change the curly single quotes into straight single quotes.
Doesn’t it work now? It does for me.