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