Macro For Deleting Rows When Certain Number/Text Appears In Certain Cell

jlkirk

Active Member
Joined
May 6, 2002
Messages
328
Office Version
  1. 365
I posted this question on Woody's, but have not heard anything, and I am under a bit of a time constraint. My worksheet contains an inventory of over 1000 auto parts. Column A is the part number, a unique number for each row (i. e., no cell in column A contains the same number); column B contains the part description, and these cells may be duplicated; column C contains the price, and, like column B, the cells in column C may contain duplicates; and finally, column D contains the quantity of each part in inventory, which, again, like columns B and C, may contain duplicates. What I would like is a macro that would delete any row with a certain part number in column A. There may be 40-50 different part numbers that I would like to include in this deleting process. I thought about filtering, but that is too time-cousuming. Any ideas?
Thanks in advance.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this: change/expand the values in red to suit

Rich (BB code):
Sub DelRows()
Dim x, LR As Long, i As Long
x = Array(1, 2, 7, "ABC")
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
    If isnumeric(Application.Match(Range("A" & i).Value, x, 0)) Then Rows(i).Delete
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,537
Messages
6,179,405
Members
452,911
Latest member
a_barila

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