IF/AND or COUNTIF with multiple named ranges

Aviles

Board Regular
Joined
Dec 17, 2008
Messages
173
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have the below formula that is not working for me when using named ranges:

=IF(AND(V2=STATE,Z2=CITY),"CUST",V2)

STATE and CITY are both named ranges on a separate sheet (STATE= BL2 and CITY= BJ2:BJ10)

When both of the conditions are met/true, the formula is not returning "CUST" like I'm expecting. It's just returning the value in V2.


I also tried using a COUNTIF formula:

=IF(COUNTIF(STATE,V2)+COUNTIF(CITY,Z2),"CUST",V2)

But now it is returning "CUST" when only 1 of the conditions are met (either one).

Any help would be appreciated, thanks.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Which Excel version are you using?
Can you post a sample data?
 
Upvote 0
This should help
Excel Formula:
=IF(AND(CITY=Z2;STATE=V2);"CUST";V2)
 
Upvote 0
This should help
Excel Formula:
=IF(AND(CITY=Z2;STATE=V2);"CUST";V2)
You're repeating what the OP have tried. CITY has multiple cells. This is not doing what the OP is expecting.
 
Upvote 0
Which Excel version are you using?
Can you post a sample data?
Hi @Cubist
I'm using Microsoft 365 MSO Version 2402 32-bit
As for the sample data, it's all just simple text values with one State in the State named range, and 9 different City's in the City named range.
Thanks.
 
Upvote 0
Assuming you are just looking for the existence of the city to be in the list....

=IF(AND(V2=STATE,COUNTIF(CITY,Z2)>0),"CUST",V2)
 
Upvote 0
Still unclear what your expected result is but try:
Excel Formula:
=IF((V2=STATE)*(Z2=CITY),"CUST",V2)
 
Upvote 0
Still unclear what your expected result is but try:
Excel Formula:
=IF((V2=STATE)*(Z2=CITY),"CUST",V2)
Sorry, should've been more clear. This formula gave me a Spill error, but thanks very much for your help.
 
Upvote 0
I'm using Microsoft 365

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,547
Members
452,925
Latest member
duyvmex

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