Deleting multiple rows based on cell value

HomePro

Board Regular
Joined
Aug 3, 2021
Messages
157
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
  10. Prefer Not To Say
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
How can I modify this code to work on a sheet rather than a table?

Sub Delete_Rows_Based_On_Multiple_Values()
'Apply a filter to a Table and delete visible rows
'Source: VBA Macro to Delete Rows Based on Cell Values or Conditions in Excel
Dim lo As ListObject
'Set reference to the sheet and Table.
' Set lo = Data.ListObjects(1)
lo.Parent.Activate 'Activate sheet that Table is on.
'Clear any existing filters
lo.AutoFilter.ShowAllData
'1. Apply Filter - Blanks in Product for before 2015 only
lo.Range.AutoFilter Field:=10, Criteria1:="yes"
lo.Range.AutoFilter Field:=11, Criteria1:="yes"
'2. Delete Rows
Application.DisplayAlerts = False
lo.DataBodyRange.SpecialCells(xlCellTypeVisible).Delete
Application.DisplayAlerts = True
'3. Clear Filter
lo.AutoFilter.ShowAllData

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Thanks but I got this to work.
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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