Upload files to "ResetFilters"
This commit is contained in:
parent
07dae31602
commit
3d1c29640a
34
ResetFilters/ResetFilters.bas
Normal file
34
ResetFilters/ResetFilters.bas
Normal file
@ -0,0 +1,34 @@
|
||||
Attribute VB_Name = "ResetFilters"
|
||||
|
||||
Sub ResetFilters()
|
||||
Dim wsData As Worksheet, wsDash As Worksheet
|
||||
Dim lastRow As Long, headerRow As Long
|
||||
Dim fullRange As Range
|
||||
|
||||
' Set references to sheets
|
||||
Set wsData = ThisWorkbook.Sheets("Datasheet")
|
||||
Set wsDash = ThisWorkbook.Sheets("Dashboard")
|
||||
|
||||
' Define last row of data
|
||||
lastRow = wsData.Cells(wsData.Rows.Count, 1).End(xlUp).Row
|
||||
headerRow = 1 ' Assuming headers are in row 1
|
||||
|
||||
' Clear previous results
|
||||
wsDash.Range("A10:L35").ClearContents
|
||||
|
||||
' Remove any active filters
|
||||
If wsData.AutoFilterMode Then wsData.AutoFilterMode = False
|
||||
|
||||
' Copy all data
|
||||
Set fullRange = wsData.Range(wsData.Cells(headerRow, 1), wsData.Cells(lastRow, wsData.UsedRange.Columns.Count))
|
||||
|
||||
' Copy headers
|
||||
wsData.Rows(headerRow).Copy Destination:=wsDash.Rows(9)
|
||||
|
||||
' Copy entire dataset
|
||||
fullRange.Offset(1, 0).Copy
|
||||
wsDash.Cells(10, 1).PasteSpecial Paste:=xlPasteValues
|
||||
wsDash.Cells(10, 1).PasteSpecial Paste:=xlPasteFormats
|
||||
Application.CutCopyMode = False
|
||||
End Sub
|
||||
|
Loading…
x
Reference in New Issue
Block a user