VBAProIWish
Well-known Member
- Joined
- Jul 6, 2009
- Messages
- 1,027
- Office Version
- 365
- Platform
- Windows
Hello All,
I currently have this code here that deletes any rows that have "Grape" in the "Fruit" column...
But the code seems pretty slow. Is there a way, using the autofilter that this code can be faster?
I was thinking, logically, it could be this way here...
1. Autofilter the entire workbook
2. Filter the fruit column for all values except "grape" or "GRAPE".
3. Delete any rows not visible, which would be any rows that contain "grape" or "GRAPE".
Can this be done via code?
Thanks much
I currently have this code here that deletes any rows that have "Grape" in the "Fruit" column...
Code:
Sub Delete_rows_with_text_x_in_col_x()
Dim cell_to_check As Variant
Dim range_to_check As Range
Dim nCol As Long
Dim rCount As Long
With ActiveSheet
nCol = Application.Match("Fruit", .Rows(1), 0)
For rCount = .UsedRange.Rows.Count To 2 Step -1
Select Case .Cells(rCount, nCol).Value
Case "grape", "GRAPE"
.Rows(rCount).EntireRow.Delete
End Select
Next
End With
But the code seems pretty slow. Is there a way, using the autofilter that this code can be faster?
I was thinking, logically, it could be this way here...
1. Autofilter the entire workbook
2. Filter the fruit column for all values except "grape" or "GRAPE".
3. Delete any rows not visible, which would be any rows that contain "grape" or "GRAPE".
Can this be done via code?
Thanks much