I am trying to create a self-cleaning pivot table from code that was copied from a google search. I am getting a syntax error. Below, is the code where I am getting the error: (it is happening on the very last row of code)
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim mDisAlerts As Boolean
If mSheet <> ActiveSheet.Name Then
On Error Resume Next
If Worksheets(mSheet).Range("A1") = _
"Remove this text to preserve this worksheet." Then
mDisAlerts = Application.DisplayAlerts
If mDisAlerts Then
Application.DisplayAlerts = False
End If
Worksheets(mSheet).Delete
Application.DisplayAlerts = mDisAlerts
End If
On Error GoTo 0
End If
End SubEnd Listing One
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim mDisAlerts As Boolean
If mSheet <> ActiveSheet.Name Then
On Error Resume Next
If Worksheets(mSheet).Range("A1") = _
"Remove this text to preserve this worksheet." Then
mDisAlerts = Application.DisplayAlerts
If mDisAlerts Then
Application.DisplayAlerts = False
End If
Worksheets(mSheet).Delete
Application.DisplayAlerts = mDisAlerts
End If
On Error GoTo 0
End If
End SubEnd Listing One