cheesypoofs
New Member
- Joined
- Mar 7, 2023
- Messages
- 9
- Office Version
- 365
- Platform
- Windows
I am making a funnel management tool and I am trying to use .AutoFilter to clear contents in a row on Table 1 if it states "installed", "scheduled", or "cancelled in the "stage" column. I do not want to delete the rows entirely because I want to keep the number of rows in the table as 100. I also want to add a warning message when the button is clicked to confirm that the user wants to run this macro since running the macro a second time with if there are no rows to clear ends up making a mess of the table and would confuse users.
This is the code I am currently trying to build on
This is the code I am currently trying to build on
VBA Code:
Sub ClearSold()
Dim dRng As Range
With ActiveSheet.ListObjects("Table1")
.Range.AutoFilter Field:=7, Criteria1:=Array("Cancelled", "Installed", "Scheduled"), Operator:=xlFilterValues
If WorksheetFunction.Subtotal(2, .DataBodyRange) > 0 Then
Set dRng = .DataBodyRange.SpecialCells(xlCellTypeVisible)
.Range.AutoFilter
dRng.ClearContents
End If
End With
End Sub