Auto populate cell based on value in corresponding cell

swannylfc

New Member
Joined
Aug 4, 2014
Messages
27
Hi there

I have a spreadsheet which has a column called 'Country'. Depending on the value of each cell in this column, another column on the row may need to be populated with another cell value (including the colour format) which is on the side of the page in a table format as below.


[TABLE="width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]CODE[/TD]
[/TR]
[TR]
[TD]Ireland[/TD]
[TD]Green[/TD]
[/TR]
[TR]
[TD]England[/TD]
[TD]Red[/TD]
[/TR]
[TR]
[TD]Scotland[/TD]
[TD]Blue[/TD]
[/TR]
[TR]
[TD]Wales[/TD]
[TD]Yellow[/TD]
[/TR]
</tbody>[/TABLE]


So in the Country column, which is F3:F200, if cell F3 = 'Ireland' I want the Code column (cell H3) to automatically show 'Green' (including the red text as shown in the above table). If F4 = 'America' - which is not on the table - then leave H4 empty. If cell F5 = 'Wales' then show 'Yellow' in H5 and so on.

Could somebody please point me in the right direction for going about accomplishing something like this, without making a giant 'IF' chain (as there are more entries in the table than in the above example). Thank-you.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
use the table above as a reference table instead.. then use the following:

H3 = IFERROR(VLOOKUP(F3, reference table, 2, 0), "")

for the formatting, just go to cell formats and change font color, all of them should be in RED anyway..


Hi there

I have a spreadsheet which has a column called 'Country'. Depending on the value of each cell in this column, another column on the row may need to be populated with another cell value (including the colour format) which is on the side of the page in a table format as below.


[TABLE="width: 500"]
<tbody>[TR]
[TD]Country[/TD]
[TD]CODE[/TD]
[/TR]
[TR]
[TD]Ireland[/TD]
[TD]Green[/TD]
[/TR]
[TR]
[TD]England[/TD]
[TD]Red[/TD]
[/TR]
[TR]
[TD]Scotland[/TD]
[TD]Blue[/TD]
[/TR]
[TR]
[TD]Wales[/TD]
[TD]Yellow[/TD]
[/TR]
</tbody>[/TABLE]


So in the Country column, which is F3:F200, if cell F3 = 'Ireland' I want the Code column (cell H3) to automatically show 'Green' (including the red text as shown in the above table). If F4 = 'America' - which is not on the table - then leave H4 empty. If cell F5 = 'Wales' then show 'Yellow' in H5 and so on.

Could somebody please point me in the right direction for going about accomplishing something like this, without making a giant 'IF' chain (as there are more entries in the table than in the above example). Thank-you.
 
Upvote 0
use the table above as a reference table instead.. then use the following:

H3 = IFERROR(VLOOKUP(F3, reference table, 2, 0), "")

for the formatting, just go to cell formats and change font color, all of them should be in RED anyway..

Hi jarjar, thanks for your answer. It is working nicey, except it is not bringing across the colour formatting. I should have mentioned that the red colour was a (bad) example, what I actually need is the text on a green background with highlighted border. That is how it is in the reference table, but it is just returning the reference table cell text and not the background nor the highlighted border. Any suggestions on how to approach this? I should point out that formatting all the cells to have green backgrounds etc wouldn't work if there is no match in the reference table I want the cell to remain white and empty (much like me, haha). I should also point out that there is another section in the reference table which has a blue background and white text.
 
Upvote 0
hmmm.. you could set the conditional formatting rules on column H based on the value, like if it contains "Green", fill it with green background and white font color, if it contains "Blue", fill it with blue background and white font color..


Hi jarjar, thanks for your answer. It is working nicey, except it is not bringing across the colour formatting. I should have mentioned that the red colour was a (bad) example, what I actually need is the text on a green background with highlighted border. That is how it is in the reference table, but it is just returning the reference table cell text and not the background nor the highlighted border. Any suggestions on how to approach this? I should point out that formatting all the cells to have green backgrounds etc wouldn't work if there is no match in the reference table I want the cell to remain white and empty (much like me, haha). I should also point out that there is another section in the reference table which has a blue background and white text.
 
Upvote 0
hmmm.. you could set the conditional formatting rules on column H based on the value, like if it contains "Green", fill it with green background and white font color, if it contains "Blue", fill it with blue background and white font color..

Thanks jarjar, I have it now. You're the man.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,636
Latest member
laura12345

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