Delete Rows based off criteria meeting

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
807
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have VBA to delete based off of data starting on row 1. But my data is going to change to start on row 11. My data is also quite large so I am worried even doing the below I may have performance issues. Could someone help me with the below?
  1. Modify the existing VBA to accommodate
  2. Adjust the method provided by Peter here to test if faster? VBA: Delete row if not match list

VBA Code:
'Delete all rows from Col. Q that equal one
'Hide all rows not equal to one
        .Columns("Q:Q").AutoFilter
        .Range("$Q$1:$Q$" & lr1).AutoFilter Field:=1, Criteria1:="1"
'Find last row in column Q with data after filter
lr2 = .Cells(rows.count, "Q").End(xlUp).row
'Skip if less than 2
    If lr2 > 2 Then
'Delete unhidden data
        .Application.DisplayAlerts = False
        .UsedRange.Offset(1, 0).Resize(ActiveSheet.UsedRange.rows.count - 1).rows.Delete
        .Application.DisplayAlerts = True
        .Range("Q1").AutoFilter
End If
        .Range("1:1").AutoFilter
        .Cells.EntireColumn.AutoFit
        .Activate
End With
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,216,806
Messages
6,132,807
Members
449,760
Latest member
letonuslepus

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