thomasuponor
New Member
- Joined
- Sep 13, 2018
- Messages
- 44
- Office Version
- 2016
- Platform
- Windows
Hi,
I have below macro that looks into column B and deletes row if one of the numbers are present.
I would want the macro to include also column C and delete the rows if these criteria are present - "MLC", "PEX"
Have tried to add an extra Set rng = ws.Range("C3:C" & lastRow) but does not work.
I have below macro that looks into column B and deletes row if one of the numbers are present.
I would want the macro to include also column C and delete the rows if these criteria are present - "MLC", "PEX"
Have tried to add an extra Set rng = ws.Range("C3:C" & lastRow) but does not work.
VBA Code:
Dim ws As Worksheet
Dim rng As Range
Dim lastRow As Long
Set ws = ActiveWorkbook.Sheets("Bilag_1")
lastRow = ws.Range("B" & ws.Rows.Count).End(xlUp).Row
Set rng = ws.Range("B3:B" & lastRow)
' filter and delete all but header row
With rng
.AutoFilter Field:=1, Operator:=xlFilterValues, Criteria1:=Array("1033080", "1033081", "1033179", "1033277", "1033084", "1033186", "1033270", "1033086", "1059576", "1059577")
.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End With
' turn off the filters
ws.AutoFilterMode = False