Conditional data validation

Zubair

Active Member
Joined
Jul 4, 2009
Messages
316
Office Version
  1. 2016
Platform
  1. Windows
Hi team,
I wanted to add conditional formatting on cell B2 based on A2 from array D2:E7, means drop down will show list from D2:D7 if cell A2 = "Number of Scenario" in a same way if A2 = "Number of Years" the list in data validation will show E2:E7.

Please help with formula.

A1:B2

ViewScenario by year
Number of Scenario


D1:E7
Number of Scenario Number of Years
Scenario 1Y1
Scenario 2Y2
Scenario 3Y3
Scenario 4Y4
Scenario 5Y5
Scenario 6Y6
Scenario 7Y7
Scenario 8Y8
Scenario 9Y9
Scenario 10Y10
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Actually, I've had an idea of doing it without VBA - using conditional formatting instead. Leave it with me.
 
Upvote 0
How about this. Using Conditional Formatting, when you change the dropdown in A2 from Number of Scenario to Number of Years (and vice versa) the font in B2 turns white and the cell fills yellow to prompt the user to make a selection.

From this:
test.xlsm
ABCDE
1ViewScenario by yearNumber of ScenarioNumber of Years
2Number of ScenarioScenario 4Scenario 1Y1
3Scenario 2Y2
4Scenario 3Y3
5Scenario 4Y4
6Scenario 5Y5
7Scenario 6Y6
8Scenario 7Y7
9Scenario 8Y8
10Scenario 9Y9
11Scenario 10Y10
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2Expression=COUNTIF(OFFSET($D$1,1,MATCH($A$2,$D$1:$E$1,0)-1,10,1),$B$2)=0textNO
Cells with Data Validation
CellAllowCriteria
A2List=$D$1:$E$1
B2List=OFFSET($D$1,1,MATCH($A$2,$D$1:$E$1,0)-1,10,1)


To this:
test.xlsm
ABCDE
1ViewScenario by yearNumber of ScenarioNumber of Years
2Number of YearsScenario 4Scenario 1Y1
3Scenario 2Y2
4Scenario 3Y3
5Scenario 4Y4
6Scenario 5Y5
7Scenario 6Y6
8Scenario 7Y7
9Scenario 8Y8
10Scenario 9Y9
11Scenario 10Y10
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2Expression=COUNTIF(OFFSET($D$1,1,MATCH($A$2,$D$1:$E$1,0)-1,10,1),$B$2)=0textNO
Cells with Data Validation
CellAllowCriteria
A2List=$D$1:$E$1
B2List=OFFSET($D$1,1,MATCH($A$2,$D$1:$E$1,0)-1,10,1)


Then this:
test.xlsm
ABCDE
1ViewScenario by yearNumber of ScenarioNumber of Years
2Number of YearsY3Scenario 1Y1
3Scenario 2Y2
4Scenario 3Y3
5Scenario 4Y4
6Scenario 5Y5
7Scenario 6Y6
8Scenario 7Y7
9Scenario 8Y8
10Scenario 9Y9
11Scenario 10Y10
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2Expression=COUNTIF(OFFSET($D$1,1,MATCH($A$2,$D$1:$E$1,0)-1,10,1),$B$2)=0textNO
Cells with Data Validation
CellAllowCriteria
A2List=$D$1:$E$1
B2List=OFFSET($D$1,1,MATCH($A$2,$D$1:$E$1,0)-1,10,1)


No VBA required, and you can change the fill colour to whatever you prefer.
 
Upvote 0
Good idea, yes I will do this, 2ndly after changing selection the heading I have linked will not appear so user can automatically understand that I need to change B2.

Many thanks
 
Upvote 0

Forum statistics

Threads
1,225,738
Messages
6,186,728
Members
453,368
Latest member
positivemind

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