Cell to return corresponding text

Goddess

Board Regular
Joined
Dec 3, 2015
Messages
112
Office Version
  1. 2021
Platform
  1. Windows
Hi, I have a table, where I need the cell to return the corresponding text based on the text I entered in another cell. However, the reference cell, in this example "car"& "van" are grouped as "others" in the data table.

I basically need the data in the yellow cells, B2:D3 to auto populate when I enter the data in cell B1:D1. Bus will have it's own unique colour code, whereas the rest of the vehicles will be grouped as "others" as they have the same colour code. Possible to do it?

Book1
ABCDEFGHIJK
1carvanbusOthersBus
2BlueBlueBlue-lightBlueBlue-light
3GreenGreenGreen-darkGreenGreen-dark
4
Sheet1
Cell Formulas
RangeFormula
B2:B3B2=I2
C2:D3C2=I2


Thanks!
Irene
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Like this?

Book1
ABCDEFGHIJ
1carvanbusOthersBus
2BlueBlueBlue-lightBlueBlue-light
3GreenGreenGreen-darkGreenGreen-dark
4
Sheet6
Cell Formulas
RangeFormula
B2:D3B2=INDEX($I$2:$J$3,0,IFERROR(MATCH(B1,$I$1:$J$1,0),1))
Dynamic array formulas.
 
Upvote 0
Solution
Similar to Eric W but by omitting the "row" argument in the INDEX function you can return the entire column.
You can also use Data Validation with the top row as the list so that input is restricted to those values, in which case you would need to add a column for "other".

1717738687831.png
 

Attachments

  • 1717737852765.png
    1717737852765.png
    15.5 KB · Views: 2
  • 1717738122782.png
    1717738122782.png
    16.5 KB · Views: 3
Last edited:
Upvote 0
hi sorry, I have another scenario...

I need to match the cells in yellow to the corresponding numbers in the blue cells. I have the number in the blue cells (H2:N5). I need those numbers to be auto populated into the yellow cells (B4:D4, B7:D7 & B10:D100

Book1
ABCDEFGHIJKLMNO
1vancarbus
2bluecountrygreencountryorangecountry
3blueblueblue-lightothers2japan6thailand7india
4223bus-light3japan5malaysia1UK
5bus-dark4india3germany9Spain
6orangeorangeorange-dark
7779
8
9greengreengreen-dark
10663
11
Sheet1
Cell Formulas
RangeFormula
B4B4=I3
C4C4=I3
D4D4=I4
B7B7=M3
C7C7=M3
D7D7=M5
B10B10=K3
C10C10=K3
D10D10=K5


Thanks!
 
Upvote 0
It looks like you're trying to do the following.
1717750269495.png

What is the purpose?
Looking at the table H2:N5 it seems to me it could be better organised (and I'm assuming on of those 3's should be an 8).
1717751154377.png
 
Upvote 0
It looks like you're trying to do the following.
View attachment 112411
What is the purpose?
Looking at the table H2:N5 it seems to me it could be better organised (and I'm assuming on of those 3's should be an 8).
View attachment 112413
Hi aarceng,

No, that's not what I'm trying to do. The numbers are random and not in sequence; it could have numerous decimal points too. The table is organised as it is because there are other corresponding data that I did not include here.

I need the numbers in the yellow cells to auto populate whenever I change the data in row B1:D1 (van, car, bus) and the cells above the yellow cells (B to D, row 4, 7 & 10).

For further context, only Bus will be colour coded with additional light or dark, whereas the other vehicles will just have the colour. Country is irrelevant in this context; I'm adding it in as there's a column in my data sheet and I'm not sure if it will affect the formula if I removed it from this scenario.

Thanks!
 
Upvote 0
Like this?

=INDEX($I$2:$J$3,0,IFERROR(MATCH(B1,$I$1:$J$1,0),1))

Hi Eric!

I'm trying to improve my knowledge with formulas & functions and I was wondering if you could explain to me how this works exactly. When I saw the OP post her question, I played around with INDEX and MATCH nested formula but could not make it work. I never thought of using IFERROR function. I did a search online for an explanation of IFERROR function but how does this all work together?
 
Upvote 0
-delete-
solution would not work in 2021.
 
Upvote 0
Hi Eric!

I'm trying to improve my knowledge with formulas & functions and I was wondering if you could explain to me how this works exactly. When I saw the OP post her question, I played around with INDEX and MATCH nested formula but could not make it work. I never thought of using IFERROR function. I did a search online for an explanation of IFERROR function but how does this all work together?
It's pretty simple, if you're familiar with the functions.

=INDEX($I$2:$J$3,0,IFERROR(MATCH(B1,$I$1:$J$1,0),1))

The MATCH part looks for the B1 value in the I1:J1 range, and returns the position of the matching value. Then the INDEX function takes the I2:J3 range, and lets you select the part of the range you want. The results of the MATCH go in the column parameter, and if you put a 0 in the row parameter (or omit it like aarceng did), then INDEX will return all the rows.

If MATCH cannot find a match for B1, it returns an error. Then the IFERROR function kicks in and replaces the error with whatever you put in the second parameter, 1 in this case. So that if there is no match for B1, it will default to the first column of the table.
 
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,139
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