Efficiency - DELETE ROWS

emukiss10

Board Regular
Joined
Nov 17, 2017
Messages
201
Hello Guys!

Help me speed up my code please.

I need to remove rows that contains specific pair of values in columns L and M.
80 and 1, 80 and 01, 80 and 03, 80 and 10 (01 and 1 are different - its all TEXT)

ex.

LM
8001
8003
8010
801

<tbody>
</tbody>


My working code is :

Code:
    Dim Fil As Long
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False


    Fil = Range("A" & Rows.count).End(xlUp).row
        With Range("A1:N" & Fil)
          .AutoFilter
          .AutoFilter field:=12, Criteria1:="80"
          .AutoFilter field:=13, Criteria1:=Array( _
                "01", "03", "1", "10"), Operator:=xlFilterValues
          .Offset(1, 0).SpecialCells(xlCellTypeVisible).Rows.Delete
        End With
    Selection.AutoFilter
    
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

This code works fine but the trick is that I have over 1.000.000 records and can it be done faster with better code??

Best Regards
W.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
just on a rough calculation, with over a 1 meg in rows, the best time would be appx 5 seconds. If you are beating that, then you are pretty much optimal.
 
Upvote 0
Thank You JLGWhiz

660.467 rows populated.
Time: 46.28 sec.

mayby filering is not the best way to work on big sheets?

Any sugestions?
 
Upvote 0
commonly for deleting entire rows of visible cells with large datasets the slowness is overcome if the data is sorted

if it can be done, sort on columns L & M to create just a few contiguous blocks to delete - instead of perhaps thousands without sorting

resort to a different (starting) order after doing the deleting, if required
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,739
Members
449,050
Latest member
excelknuckles

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