ItalianPlatinum
Well-known Member
- Joined
- Mar 23, 2017
- Messages
- 880
- Office Version
- 365
- 2019
- Platform
- 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?
- Modify the existing VBA to accommodate
- 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