VBA for deleting rows in a table based on value in a column

SomethngWicked

Board Regular
Joined
Feb 18, 2015
Messages
80
Hi, can someone please help regarding a VBA solution that could delete rows in a table that are extraneous? For example, I have a table of data that's generated each month and there's quite a few vendor values that aren't needed and require manual filtering/deletion. The range of data can vary (it's usually around 60,000 rows). What I essentially need is for the VBA to scan through the below example table and if vendor = Granny Smith, Golden Delicious, or Fuji, it would highlight and delete the entire row. After the VBA runs, there'd only be two rows in the table for Mcintosh and Honeycrip. If there's another (easier) way to accomplish this, please let me know. Thanks so much for the help!

Type of Food:Color:Vendor
AppleRedFuji
AppleGreenGranny Smith
AppleRedMcIntosh
AppleRedHoneycrisp
AppleRedGolden Delicious
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Maybe this:
VBA Code:
Sub DelRowsR()
Dim i As Long
Dim ws As Worksheet
Set ws = ActiveSheet

Application.ScreenUpdating = False

For i = ws.Range("C" & Rows.Count).End(xlUp).Row To 2 Step -1
    If ws.Range("C" & i).Value = "Fuji" Or ws.Range("C" & i).Value = "Granny Smith" Or ws.Range("C" & i).Value = "Golden Delicious" Then ws.Range("C" & i).EntireRow.Delete
Next

Application.ScreenUpdating = True
End Sub
 
Upvote 1
Solution

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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