VBA code to delete rows based off of criteria in a column

jrosen12

New Member
Joined
Aug 10, 2018
Messages
7
Hello,

I am looking for a code that searches worksheet called Checks_Export in Column B, and any rows that DOES NOT have BHP in Column B are deleted

Thank you!
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,474
Office Version
  1. 365
Platform
  1. Windows
Hi & welcome to MrExcel
How about
Code:
Sub FilterDelete()

   With Sheets("Checks_Export")
      If .AutoFilterMode Then .AutoFilterMode = False
      .Range("B:B").AutoFilter 1, "<>BHP"
      .AutoFilter.Range.Offset(1).EntireRow.Delete
      .AutoFilterMode = False
   End With
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,109,250
Messages
5,527,635
Members
409,778
Latest member
MagalieD

This Week's Hot Topics

Top