How to check the Sheet name exist before running Macro code
Copy the below function and use that in code as below
Sub Macro()
'If sheet do not exist then exit procedure
If Not IsSheetExists("mySheet") Then Exit Sub
End Sub
Function IsSheetExists(strSheet As String) As Boolean
On Error Resume Next
Dim ws As Worksheet
Set ws = Sheets(strSheet)
If Not ws Is Nothing Then IsSheetExists = True
End Function
--
Jacob
"tlee" wrote:
Hello all,
Could anyone know how to check the sheet name (e.g. "mySheet") exist before
running the rest macro code ?
Thanks,
tlee
.
|