View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
tlee tlee is offline
external usenet poster
 
Posts: 40
Default How to check the Sheet name exist before running Macro code

Hi Jacob,

Thank you very much for your help !

tlee

-----------------------------------------------------------------------------------------------------------
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


.