Nutterhead
New Member
- Joined
- Apr 25, 2017
- Messages
- 27
I have this bit of code for a sheet I'm having an issue with. The code is in a template and then the template is saved with a different name. The part of the code in italics ran fine by itself but then when I went to add code to exit the sub IF the workbook name is not equal to Billing Template.xlsm I ran into issues. Below is the code and I'm not sure what I'm missing or have wrong.
Private Sub Workbook_Open()
If ActiveWorkbook.Name <> "Billing Template.xlsm" Then
Exit Sub
Else
Dim ans As String
ans = MsgBox("Starting a new days report?", vbYesNo)
If ans = vbNo Then
Exit Sub
Else
Worksheets("billingtemplate").Range("A2:I100").ClearContents
Worksheets("billingtemplate").Range("M5").ClearContents
Worksheets("billingtemplate").Range("M6").ClearContents
End If
End If
End Sub
Private Sub Workbook_Open()
If ActiveWorkbook.Name <> "Billing Template.xlsm" Then
Exit Sub
Else
Dim ans As String
ans = MsgBox("Starting a new days report?", vbYesNo)
If ans = vbNo Then
Exit Sub
Else
Worksheets("billingtemplate").Range("A2:I100").ClearContents
Worksheets("billingtemplate").Range("M5").ClearContents
Worksheets("billingtemplate").Range("M6").ClearContents
End If
End If
End Sub