deleting rows containing 2 to 4 numbers

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
510
Office Version
  1. 365
Platform
  1. Windows
i have a file with thousands of lines, each line have 4 cells, each cell have 1 number (no empty lines, starting with a1)
i need a macro which can delete any line/row who doesn't contain the one of the 4 numbers i will set each time
for example: each row who doesn't have either 5 or 4 or 3 or 2 will be deleted, and sometimes the range can be only 2 or 3 numbers (like 5, 4 and 6 or 2 and 1)
can anyone help me out?

1234
ABCD
16625
26144
36556
42215
54221
61611
72212
82225
93511
106171
114211
121661
131316
143245
153462
166511
175154
181626
194162
202133
216441
221324
1234
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
anyone?

please tell me if it's ok to bump the question up or am i allowed to ask again in a few days?
 
Upvote 0
please tell me if it's ok to bump the question up or am i allowed to ask again in a few days?
We usually advise waiting for 24 hours to make the first bump, and bump once a day after that.

Very curious, you seem to have a lot of similiar questions with minor twists each time.
Is this some sort of school project/assignment?

Since you already had a few of them answered, you may want to study those techniques, and see if you can come up with your own solutions, and if you are unable, post what you attempted.
 
Upvote 0
you can say it's a private project of mine,

already tried to, with Similar threads found in this forum here, and in google,
tried to edit/modified them but with no success
for this moment, i only left with 4 or 5 of questions (maybe i'll slow down asking them)
in the meantime, i'll still glad to get help with the one above

and in any case:
do you have in mind some place online (for free) which i can learned macro/formulas for excell EASY way?
 
Upvote 0
do you have in mind some place online (for free) which i can learned macro/formulas for excell EASY way?
There are TONS of free tutorials and YouYube videos that can be found with some simple Google searches.

MrExcel also sells many books on a wide variety of topics, including VBA (found here: Products), and hundeds of videos, which can be found here: MrExcel Excel Videos
 
Upvote 0
For your current problem, one simple way (that does not require you to know VBA) would be to do something like the answer for this first question you submitted: finding duplicate rows (multiple cells)

You can use a Helper Column which adds up four COUNTIF formulas (count the number of 2s + count the number of 3s + count the number of 4s + count the number of 5s).
Then you can delete any row where that SUM is 0.
 
Upvote 0
tnx
manage to do it,
but the process is longer and since i need every time to check and replace numbers and run several tests i'll try working out a macro
thank you!
 
Upvote 0
If you prefer automated/VBA solutions, that is a good thing to put in your initial post, so people have a better idea of exactly what you are looking for.

You may be able to do something like what Rick Rothstein showed you back here: deleting identical numbers
 
Upvote 0

Forum statistics

Threads
1,214,819
Messages
6,121,737
Members
449,050
Latest member
excelknuckles

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