Hi,
I tried to delete some of the tabs that are to be replaced by Export of SAS (Statistical Analysis Software) application. But as I ran it, I got error 9 on the yellow line below and on error resume next won't work. The funny thing is that as I debugged, Excel pointed to some macros that had nothing much to do with the deleting process (like UpdateChart below). How can leave UpdateChart alone as I delete those tabs? I tried EnableEvents=0 but not working.
What should I do?
Thanks in advance.
Private Sub UpdateChart()
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error GoTo errHandler
Dim strSelection As String
Dim wsD As Worksheet
Dim wsC As Worksheet
Dim wsE As Worksheet
Set wsD = Worksheets("VolumeShareChartData")
Set wsC = Worksheets("RegionKeyAcctMetrics")
Set wsE = Worksheets("VolumeShareCharts")
Set wsF = Worksheets("AreaKeyAcctMetrics")
Set wsG = Worksheets("DistrictKeyAcctMetrics")
Set wsH = Worksheets("PodKeyAcctMetrics")
Set wsR = Worksheets("RDAMKeyAcctMetrics")
Set wsK = Worksheets("StateKeyAcctMetrics")
strSelection = Range("AA1").Text
'MsgBox "strselect " & strSelection
...
...
I tried to delete some of the tabs that are to be replaced by Export of SAS (Statistical Analysis Software) application. But as I ran it, I got error 9 on the yellow line below and on error resume next won't work. The funny thing is that as I debugged, Excel pointed to some macros that had nothing much to do with the deleting process (like UpdateChart below). How can leave UpdateChart alone as I delete those tabs? I tried EnableEvents=0 but not working.
What should I do?
Thanks in advance.
Code:
Sub DeleteSheets()
On Error Resume Next
Application.DisplayAlerts = False
For Each st In Worksheets
If UCase(st.Name) <> "REPORTMONTHS" And _
UCase(st.Name) <> "CRITERIA" And _
UCase(st.Name) <> "GRAPHGEODATASHEET" And _
UCase(st.Name) <> "GRAPHDATASHEET" And _
UCase(st.Name) <> "NOTES" And _
UCase(st.Name) <> "DATAVIEW" And _
UCase(st.Name) <> "VOLUMESHARECHARTDATA" And _
UCase(st.Name) <> "VIEWGRAPHS" And _
UCase(st.Name) <> "VOLUMESHARECHARTS" And _
UCase(st.Name) <> "HELP TAB" And _
UCase(st.Name) <> "PRODMKT" And _
UCase(st.Name) <> "GEOPLANLIST" Then
st.Delete
End If
Next
Application.DisplayAlerts = 1
End Sub
Private Sub UpdateChart()
Application.ScreenUpdating = False
Application.EnableEvents = False
'On Error GoTo errHandler
Dim strSelection As String
Dim wsD As Worksheet
Dim wsC As Worksheet
Dim wsE As Worksheet
Set wsD = Worksheets("VolumeShareChartData")
Set wsC = Worksheets("RegionKeyAcctMetrics")
Set wsE = Worksheets("VolumeShareCharts")
Set wsF = Worksheets("AreaKeyAcctMetrics")
Set wsG = Worksheets("DistrictKeyAcctMetrics")
Set wsH = Worksheets("PodKeyAcctMetrics")
Set wsR = Worksheets("RDAMKeyAcctMetrics")
Set wsK = Worksheets("StateKeyAcctMetrics")
strSelection = Range("AA1").Text
'MsgBox "strselect " & strSelection
...
...