Display alternate text based on value in another cell

RodneyW

Active Member
Joined
Sep 24, 2010
Messages
479
Office Version
  1. 2013
Platform
  1. Windows
I need a formula that will display values based on content in another cell. Cell M4 will have a value of either San Mateo or San Jose. (It actually isn't a hard coded value but is pulling a value based on a pivot table) In the cell where my formula will be, I need it to display 1 if the value in M4 is San Mateo or 2 if the value in M4 is San Jose.

Something along the lines of this: =IF(M4=San Mateo,"1",IF(M4=San Jose,"2")) which doesn't work, but this does =IF(M4=SanMateo,"1",IF(M4=SanJose,"2"))
Because other cells are dependent on M4 reading San Mateo vs SanMateo, I need a workaround.

Any ideas?

Thanks in advance
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
=IF(M4=San Mateo,"1",IF(M4=San Jose,"2"))
you need "" around the name and NOT around the numbers - "1" is seen as text and not a number so use 1
=IF(M4="San Mateo",1,IF(M4="San Jose",2, "no a match"))

you didnt have a FALSE so what if M4 does not = "San Mateo" or "San Jose" what do you want in M4

whats actually in the cell
"San Mateo"
or
"SanMateo"

=IF(M4=SanMateo,"1",IF(M4=SanJose,"2")) - should not work without the """
 
Upvote 0
Solution
=IF(M4=San Mateo,"1",IF(M4=San Jose,"2"))
you need "" around the name and NOT around the numbers - "1" is seen as text and not a number so use 1
=IF(M4="San Mateo",1,IF(M4="San Jose",2, "no a match"))

you didnt have a FALSE so what if M4 does not = "San Mateo" or "San Jose" what do you want in M4

whats actually in the cell
"San Mateo"
or
"SanMateo"

=IF(M4=SanMateo,"1",IF(M4=SanJose,"2")) - should not work without the """
I've moved the quotes around the city instead of the number and that solved it. M4 will never be anything other than San Mateo or San Jose. If a new city is added, the pivot table it pulls from would add the new city. If the new city was Albany, I'd change the formula to include the third city. THANK YOU for the solution.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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