If Multiple Condition and Nested CountIf Formula Not Working

TropicalMagic

New Member
Joined
Jun 19, 2021
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Hi all,



I would like to:



Check if row value in Column AM = "APAC"

Check if row value in Column AR = "APAC"

Check if row value in Column AJ has partial string match containing "OFIA"

Check if row value in Column AJ has partial string match containing "Intra-Asia"



If all above conditions are true, return 1 in Column BM, else return 0 in Column BM.



However, my formula entered below is not returning any 1s, only 0s:


Range("BM2")

=IF(AND(AM2="APAC",AR2="APAC",COUNTIF(AJ2,"*OFIA*"),COUNTIF(AJ2,"*Intra-Asia*")),1,0)



Many thanks!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
In that case there is nothing wrong with your formula. Are you sure that there are rows with APAC in both AM & AR and AJ has both OFIA & Intra-Asia in the same cell?
 
Upvote 0
In that case there is nothing wrong with your formula. Are you sure that there are rows with APAC in both AM & AR and AJ has both OFIA & Intra-Asia in the same cell?
Ahhh apologies! What if AJ need Either OFIA OR Intra-Asia in the same cell?
 
Upvote 0
Hi,

Then, you can use just this:

Excel Formula:
=--AND(AM2="APAC",AR2="APAC",SUM(COUNTIF(AJ2,{"*OFIA*","*Intra-Asia*"})))
Brilliant, thanks!

It was what I was looking for!

I amended it a little for my usage - At Range("BM2") :

=IF(AND(AM2="APAC",AR2="APAC",SUM(COUNTIF(AJ2,{"*OFIA*","*Intra-Asia*"}))),1,0)
 
Upvote 0
Brilliant, thanks!

It was what I was looking for!

I amended it a little for my usage - At Range("BM2") :

=IF(AND(AM2="APAC",AR2="APAC",SUM(COUNTIF(AJ2,{"*OFIA*","*Intra-Asia*"}))),1,0)

You Don't need the IF(...,1,0)

My formula, as posted above:

Excel Formula:
=--AND(AM2="APAC",AR2="APAC",SUM(COUNTIF(AJ2,{"*OFIA*","*Intra-Asia*"})))

Will produce the 1 and 0 results as you require.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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