assign Incremental numbers in new column based on criteria from two columns

mena139

New Member
Joined
Dec 2, 2016
Messages
14
I am looking for assistance in setting up a formula to return incremental values to a list (including duplicates) only when selected values are present in a different column. Please see the example attached,

if the produce is apples, banana or peach assign the number (1,2,3) representing the city it comes from.
 

Attachments

  • Capture.PNG
    Capture.PNG
    10.4 KB · Views: 16

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.
I want the formula to return the following in the last column. the idea being that if the produce listed at the bottom comes from new york it will assign a "1". if it comes from chicago it will assign a "2"
if it comes from atlanta then it will assign a "3". at the same time though if the value in the second column is not on the list of produce (ie tomatoes) then leave third column blank
Capture2.PNG
 

Attachments

  • Capture2.PNG
    Capture2.PNG
    10.8 KB · Views: 7
Upvote 0
Hi Mena139,

I think this does what you want but what should happen if the city is not in the list?

Book2
ABC
1CityProduceValue Code
2New Yorkapples1
3New Yorkbanana1
4New Yorkpeach1
5New Yorktomato 
6Chicagoapples2
7Chicagobanana2
8Chicagopeach2
9Chicagotomato 
10Atlantaapples3
11Atlantabanana3
12Atlantapeach3
13Atlantatomato 
14
15
16Only IfCities
17applesNew York1
18bananaChicago2
19peachAtlanta3
Sheet1
Cell Formulas
RangeFormula
C2:C13C2=IF(ISNA(MATCH(B2,$A$17:$A$19,0)),"",INDEX($C$17:$C$19,MATCH(A2,$B$17:$B$19,0)))
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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