Update ClearReports/ClearReports.bas
This commit is contained in:
parent
4af67db419
commit
b2e084bd10
@ -1,37 +1,35 @@
|
|||||||
Attribute VB_Name = "ClearReports"
|
Sub ClearReportsButton()
|
||||||
Sub ClearReportsButton()
|
Dim ws As Worksheet
|
||||||
Dim ws As Worksheet
|
Dim wsArr As Variant
|
||||||
Dim wsArr As Variant
|
Dim i As Integer
|
||||||
Dim i As Integer
|
|
||||||
|
' Define sheets to keep
|
||||||
' Define sheets to keep
|
wsArr = Array("Dashboard", "Datasheet", "Code")
|
||||||
wsArr = Array("Dashboard", "Datasheet", "Code")
|
|
||||||
|
Application.ScreenUpdating = False
|
||||||
Application.ScreenUpdating = False
|
Application.DisplayAlerts = False
|
||||||
Application.DisplayAlerts = False
|
|
||||||
|
' Loop backwards to avoid deletion issues
|
||||||
' Loop backwards to avoid deletion issues
|
For i = ThisWorkbook.Sheets.Count To 1 Step -1
|
||||||
For i = ThisWorkbook.Sheets.Count To 1 Step -1
|
Set ws = ThisWorkbook.Sheets(i)
|
||||||
Set ws = ThisWorkbook.Sheets(i)
|
If Not IsInArray(ws.Name, wsArr) Then
|
||||||
If Not IsInArray(ws.Name, wsArr) Then
|
ws.Delete
|
||||||
ws.Delete
|
End If
|
||||||
End If
|
Next i
|
||||||
Next i
|
|
||||||
|
Application.DisplayAlerts = True
|
||||||
Application.DisplayAlerts = True
|
Application.ScreenUpdating = True
|
||||||
Application.ScreenUpdating = True
|
MsgBox "All county reports have been cleared!", vbInformation
|
||||||
MsgBox "All county reports have been cleared!", vbInformation
|
End Sub
|
||||||
End Sub
|
|
||||||
|
' Function to check if sheet name is in the list of sheets to keep
|
||||||
' Function to check if sheet name is in the list of sheets to keep
|
Function IsInArray(val As String, arr As Variant) As Boolean
|
||||||
Function IsInArray(val As String, arr As Variant) As Boolean
|
Dim i As Integer
|
||||||
Dim i As Integer
|
For i = LBound(arr) To UBound(arr)
|
||||||
For i = LBound(arr) To UBound(arr)
|
If arr(i) = val Then
|
||||||
If arr(i) = val Then
|
IsInArray = True
|
||||||
IsInArray = True
|
Exit Function
|
||||||
Exit Function
|
End If
|
||||||
End If
|
Next i
|
||||||
Next i
|
IsInArray = False
|
||||||
IsInArray = False
|
End Function
|
||||||
End Function
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user