I have the below vba code on my workbook, but I’m getting the below runtime error, please advice.
>>> use code - tags <<<
>>> use code - tags <<<
Code:
Sub CopyMyWorkSheet()
Dim sNm As String
sNm = "MyWorkSheet " & Format(DateAdd("m", 1, [E3].Value), "mm-dd-yy")
If Not WksExists(wsc.Name) Then < Run-time error 424; Object required…here
ThisWorkbook.Unprotected "Password”"
ActiveSheet.Copy
ActiveSheet.Name = sNm
ThisWorkbook.Protect”Password”
Else: Exit Sub
End If
End Sub
''///this code in a separate module Function
Function WksExists(wksName As String) As Boolean
On Error Resume Next
WksExists = CBool(Len(Worksheets(wksName).Name) > 0)
End Function
Last edited by a moderator: