0% found this document useful (0 votes)
12 views1 page

AddSheetError Solution 01

Uploaded by

santhoshra8680
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

AddSheetError Solution 01

Uploaded by

santhoshra8680
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Private Sub btnAddWorksheet_Click()

' variable for the tryAgain logic below


Dim tryAgain As Integer

' if the user leaves the box empty go to the error handler section
On Error GoTo errHandler

[Link] before:=Worksheets(1)

[Link] = InputBox("Please enter a new worksheet name")

' if no error skip the errHandler


Exit Sub

' error handler section


errHandler:
' prompt the user to try again
tryAgain = MsgBox("Invalid Worksheet Name", vbYesNo)

' if the user picked yes


If tryAgain = 6 Then
're-run the procedure
btnAddWorksheet_Click
Else
' turn off the alert of deleting the worksheet if the user selects no
[Link] = False

' delete the invalid worksheet


[Link]
End If
End Sub

You might also like