Deleting Filtered Rows - Speeding it up

Lovelylou79

New Member
Joined
Sep 4, 2017
Messages
37
Hi All,

I have the following code that filters a sheet then deletes the visible rows. The problem is, it takes a very long time to run.

'Deletes "Comments:" rows with Auto Filter
With ActiveSheet
.AutoFilterMode = False
With Range("A1", Range("A" & Rows.Count).End(xlUp))
.AutoFilter 1, "*Comments:*"
On Error Resume Next
.offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With

The "Comments' Row first appears at row 7 then every 6th row after that, ie; 7, 13, 19, 25.
Ideally I'd like the Comments rows and the row below it be deleted.

Is there a code or an alteration to my current code that can speed up the process?

Thank you in advance,
 
Hi All, Thank you for all your suggestions.
Unfortunately none of these helped reduce the time this process takes.
The workbook that took 26 mins must have had something else going on with it, the file itself took 10 min to open and another 10 to enable it for editing. The workbooks this macro is run on is received from a variety of sources, so not always clean.
The code still takes 10 -11 mins to run on an ideal workbook with approx 1200 rows.
I'm still open to any other suggestions.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Do you have any conditional formatting?
 
Upvote 0
You may also have some phantom bloated ranges in the book. Do you know how to check for that. How big in terms of megabytes is the workbook.
 
Upvote 0
I don't know how to check for phantom bloated ranges. The size of the work book is a time sheet, the size depends on how many ppl are listed, how many shifts, and how many days of the month are covered. They can range from 300k to 2MB.

I did come up with a fix though....I have deleted this part of my code and increased "i" from 4 to 5 to read the extra row in a different section of my code...so simple. Apologies for wasting your time!
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,015
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top