Need help to look through column to find value/s

rharri1972

Board Regular
Joined
Nov 12, 2021
Messages
132
Office Version
  1. 2019
Platform
  1. Windows
I have a worksheet("Sheet 1") range is A4:M2000

I want to use VBA to look through Column M to find a value and then once found it will delete that entire row.

Here is the dilemma... there will be several values to find.

Example...this column is Vendors. I am trying to delete several different vendors with one script if possible. We can use Vendors "A" "B" "C" for demsonstration purposes. I don't know if this will be a loop or whatever.
So if this possible your help will be GREATLY appreciated!!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
How many vendors do you have?
Could the list of vendors be stored somewhere, i.e. either in a list on a sheet somewhere, or in an VBA array?
 
Upvote 0
How many vendors do you have?
Could the list of vendors be stored somewhere, i.e. either in a list on a sheet somewhere, or in an VBA array?
Hey Joe...Thanks for your reply. So this report is actually created in our company's management software and I pull it into an xl file and sort from there what i need so the vendor column is already generated and Im trying to keep from having to manually sort through to delete. I have about 8-9 different vendors...currently i have macros for each vendor but am trying to make it one for all. even though only 8-9 vendors but about 2000 lines worth of information.
 
Last edited:
Upvote 0
One way would be to store the list of vendors in an array, and see if the entry for a current row exists in that array.
Andrew's response here shows you one way on how to do that: check if value exists in a vba array
 
Upvote 0
thank you Joe for your input. Would anyone else have any ideas of whether or not there is a way to do a loop in VBA until all set criteria is met. Looking through one column and deleting entire row for each vendor found that is to be excluded? Vendors "A", "B", "C", and "D"?
 
Upvote 0
thank you Joe for your input. Would anyone else have any ideas of whether or not there is a way to do a loop in VBA until all set criteria is met. Looking through one column and deleting entire row for each vendor found that is to be excluded? Vendors "A", "B", "C", and "D"?
I already told you how to do that. What is the issue with the suggestion?
You have to have some way of telling VBA all the different values (VBA can do a lot of things, but reading minds is not one of them!).
So you need to have a list somewhere, either on a sheet somewhere, or directly in VBA.

Once we have this list, we can loop through the values and the rows and do the deletions.
If you need help formulating this solution, I can help you. But you need to tell me how you would like to proceed, regarding where this list of values we need to search for will exist.
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,170
Members
448,870
Latest member
max_pedreira

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