If/then

craigwojo

Active Member
Joined
Jan 7, 2005
Messages
274
Office Version
  1. 365
Platform
  1. Windows
In cell "B1" I have a data validation (LIST). The validation list consists of the data "A,B,C,D,E,F,G" (within the drop-down).

I want cell D1 to auto-insert data from the drop-down list in "B1" For instance... If I select "B1" with the data "A", I would like to have "D1" fill with the word "yellow". If I choose "B" in the drop-down list, "D1" would fill with the data "green", ect..

I've done this before but forgot how do do it, I been off excel for a couple of years and being an "every once in a while" user I forget some things.

Thank you and God bless,

Craig
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Insert additional "Case" statements as needed. Close the code window to return to your sheet. Make a selection in B1.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("B1")) Is Nothing Then Exit Sub
    Select Case Target.Value
        Case "A"
            Target.Offset(, 3) = "yellow"
        Case "B"
            Target.Offset(, 3) = "green"
    End Select
End Sub
 
Upvote 0
In D1:
Code:
=IF(B1="","",LOOKUP(B1,{"A","B","C","D","E","F","G"},{"color1","color2","color3","color4","color5","color6","color7"}))
substitute your preferred colors for "color1","color2", ....
 
Upvote 0
Thank you both so much,
God bless,
Craig
 
Last edited:
Upvote 0
JoeMo,

When I make a validation list for "B1" it doesn't correspond to the answer in cell "D1"
I needed to change the validation list to the following list names...
TAGS - Metal Detectable Hardback
TAGS - Non-MD Hardback
TAGS - VINYL
PLACARDS - Metal Detectable Hardback
PLACARDS - Non-MD Hardback
PLACARDS - VINYL
OTHER

and the answers would be 1.00, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00
 
Upvote 0
JoeMo,

When I make a validation list for "B1" it doesn't correspond to the answer in cell "D1"
I needed to change the validation list to the following list names...
TAGS - Metal Detectable Hardback
TAGS - Non-MD Hardback
TAGS - VINYL
PLACARDS - Metal Detectable Hardback
PLACARDS - Non-MD Hardback
PLACARDS - VINYL
OTHER

and the answers would be 1.00, 2.00, 3.00, 4.00, 5.00, 6.00, 7.00
Why didn't you give us that information with your OP? Would save us all some time. Post the version of the formula I gave you that you have placed in D1.
 
Upvote 0
Another option would be to create a lookup table, then you can use a Vlookup to get the value you want.
 
Upvote 0
Thank you, everyone... just getting trying to set this up and cannot find a way to explain. Anyways... I will research it and learn. Thank you for trying and answer though. Have a great day.
 
Upvote 0
If you create a list like


Book1
AB
1TextValues
2TAGS - Metal Detectable Hardback1.00
3TAGS - Non-MD Hardback2.00
4TAGS - VINYL3.00
5PLACARDS - Metal Detectable Hardback4.00
6PLACARDS - Non-MD Hardback5.00
7PLACARDS - VINYL6.00
8OTHER7.00
List


You can then use this formula in D1
=VLOOKUP(B1,List!A2:B8,2,0)
change sheet name in red along with the range, to suit
 
Upvote 0

Forum statistics

Threads
1,223,744
Messages
6,174,254
Members
452,553
Latest member
red83

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