Populating a Column Based Off of Two Columns Values

MDean3313

New Member
Joined
Jul 8, 2019
Messages
13
Hi Everyone,

I've posted a similar question, but am having new troubles.

One column has 4 values, T12, T8, empty cells, and #VALUE !. The second column has values 1 through 4.

The new column needs to take the value from the second column (numbers 1-4) and match it to a title. For example, if a cells value is 1, the new column would say "Metropolitan", if it's 2, the new column would say "Micropolitan", if 3, the new column would say "Small Town" and 4 would be "Urban."

Additionally, I want to only populate the new column if it correlates with "T12" or "T8" and to leave blank if there is an empty cell or a #VALUE ! from the other column.

Let me know if you have any questions and thanks for the help!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Is one of these what you want?


Book1
ABCDEF
1Column AValueExtractExtract2
2T121MetropolitanMetropolitan
3T82MicropolitanMicropolitan
4T123Small TownSmall Town
5T124UrbanUrban
61Urban
72Metropolitan
8#VALUE!3
9T124Urban
10#VALUE!1
11T81Metropolitan
12
Sheet1
Cell Formulas
RangeFormula
F2=IFERROR(IF(OR(A2={"T12","T8"}),CHOOSE(B2,"Metropolitan","Micropolitan","Small Town","Urban"),""),"")
D2{=IFERROR(CHOOSE(INDEX($B$2:$B$20,SMALL(IF(NOT(ISERROR($A$2:$A$20)),IF(LEFT($A$2:$A$20)="T",ROW($A$2:$A$20)-ROW($A$2)+1)),ROWS($D$2:$D2))),"Metropolitan","Micropolitan","Small Town","Urban"),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Slightly shorter versions of both formulas:


Book1
ABCDEF
1Column AValueExtractExtract2
2T121MetropolitanMetropolitan
3T82MicropolitanMicropolitan
4T123Small TownSmall Town
5T124UrbanUrban
61Urban
72Metropolitan
8#VALUE!3
9T124Urban
10#VALUE!1
11T81Metropolitan
Sheet1
Cell Formulas
RangeFormula
D2=IFERROR(CHOOSE(INDEX($B$2:$B$20,AGGREGATE(15,6,(ROW($B$2:$B$20)-ROW($B$2)+1)/(LEFT($A$2:$A$20)="T"),ROWS($D$2:$D2))),"Metropolitan","Micropolitan","Small Town","Urban"),"")
F2=IF(ISERROR(RIGHT(A2)+0),"",CHOOSE(B2,"Metropolitan","Micropolitan","Small Town","Urban"))
 
Upvote 0
Is one of these what you want?

ABCDEF
Column AValueExtractExtract2
T12MetropolitanMetropolitan
T8MicropolitanMicropolitan
T12Small TownSmall Town
T12UrbanUrban
Urban
Metropolitan
T12Urban
T8Metropolitan

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]

[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]2[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]4[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: right"][/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: right"][/TD]
[TD="align: right"]2[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]8[/TD]
[TD="align: right"]#VALUE![/TD]
[TD="align: right"]3[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]9[/TD]

[TD="align: right"]4[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]10[/TD]
[TD="align: right"]#VALUE![/TD]
[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]11[/TD]

[TD="align: right"]1[/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]

[TD="align: center"]12[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]F2[/TH]
[TD="align: left"]=IFERROR(IF(OR(A2={"T12","T8"}),CHOOSE(B2,"Metropolitan","Micropolitan","Small Town","Urban"),""),"")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10px"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10px, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D2[/TH]
[TD="align: left"]{=IFERROR(CHOOSE(INDEX($B$2:$B$20,SMALL(IF(NOT(ISERROR($A$2:$A$20)),IF(LEFT($A$2:$A$20)="T",ROW($A$2:$A$20)-ROW($A$2)+1)),ROWS($D$2:$D2))),"Metropolitan","Micropolitan","Small Town","Urban"),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]

Thank you for this Eric!
The Worksheet Formula was able to solve my problem.
I really appreciate the help!
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
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