Romano_odK
Active Member
- Joined
- Jun 4, 2020
- Messages
- 379
- Office Version
- 365
- Platform
- Windows
Good afternoon,
A while ago I go this from Peter. This works perfect in deleting the rows that are not visible. How do I change this so it will filter values that are visible?
Thank you for your time.
Romano
A while ago I go this from Peter. This works perfect in deleting the rows that are not visible. How do I change this so it will filter values that are visible?
Thank you for your time.
Romano
VBA Code:
Private Sub CommandButton9_Click()
Application.EnableEvents = False
Application.ScreenUpdating = False
With ActiveSheet.ListObjects(1)
.ListColumns.Add Position:=2
On Error Resume Next
.ListColumns(2).DataBodyRange.SpecialCells(xlVisible).Value = 1
On Error GoTo 0
If .Parent.FilterMode Then .Parent.ShowAllData
.Sort.SortFields.Clear
.Sort.SortFields.Add2 Key:=.ListColumns(2).DataBodyRange, SortOn:=xlSortOnValues, Order:=xlAscending
.Sort.Apply
On Error Resume Next
.ListColumns(2).DataBodyRange.SpecialCells(xlBlanks).EntireRow.Delete
On Error GoTo 0
.ListColumns(2).Delete
End With
Application.ScreenUpdating = True
Application.EnableEvents = False
End Sub