Excel IF and AND formula?

bfletcher

New Member
Joined
Jul 27, 2021
Messages
6
Office Version
  1. 2013
Platform
  1. Windows
I am sure this will be easy for the experts here but wondering how this can be done. Column A will have numerous codes that can also contain duplicates. Column B will have a series of years listed in it. So basically I want a formula to look into column A and it will look at the codes there...then look for a specific year in Column B (let's say 2021). When it finds the codes in column A...and identifies that at least one of those codes matches with the year 2021, it will identify ALL of those matching codes in Column A to be deleted. So that it would look something like this:

EXCEL_MxrY5uCXKM.png


Perhaps there is a better formula to do this with. I was attempting to do an IF and AND formula and I could kind of get it to work but not quite. :) I apologize in advance if this is simplistic. I am still learning. :) Also to note, I am using Excel 2013. Thank you.
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Hi & welcome to MrExcel.
How about
Excel Formula:
=IF(COUNTIFS(A:A,A2,B:B,$D$1),"del","")
 
Upvote 0
Hi bfletcher,

Welcome to the forum!

Here's a possible solution I slapped together real quick.

In Col C: =IF(B5=$F$4, 1, 0)
In Col D: =IF(SUMIF($A$5:$A$16,A5,$C$5:$C$16)>=1, "del", "")

Create a custom conditional formatting that will Highlight each row if D = "del"

highlightDeleteRows.gif
 
Upvote 0
Wow. You guys are fantastic and have to admit, I am feeling a little dumb. lol! So glad I found this resource and cannot wait to see what else I can learn (there's just so much to still learn(. Thank you so much!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Happy to help!

Here's a screenshot of how to apply the custom conditional formatting, if needed. Change the cell reference to whatever first cell has the "del" in it. Be sure to only lock the Column reference in this condition so it can be drug down without error.

1627410610914.png
 
Upvote 0

Forum statistics

Threads
1,214,561
Messages
6,120,231
Members
448,951
Latest member
jennlynn

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