Multiple IF function in Data validation

IDRIS86

Board Regular
Joined
Mar 18, 2021
Messages
82
Office Version
  1. 365
Platform
  1. Windows
Hi, I am trying to make a drop down with multiple If function in data validation. But I couldn't make it. Please assist.

My requirement is based on N28 input in sheet1, it needs to refer table "MODEL" at list sheet.

Condition is if the N28 input is equal to B5 to B8, then dropdown to be provided with E5 & E6.

And if N28 input is equal to B9 to B12, then dropdown to be provided with F5.

Sheet (LIST 1)

Worksheet 3.xlsx
ABCDEFG
2
3
4TYPESLEEVEOTHERS
5FSDYESNONE
6FDNO
7SD
8CD
9LR
10ATN
11ND
12BD
13
List



Sheet 1

Worksheet 3.xlsx
NO
26TYPESLEEVE
27
28 FD NO
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
O28Cell Valuecontains "NO"textNO
Cells with Data Validation
CellAllowCriteria
N28:N89List=TYPE
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
What about this in O28?

1616540017438.png


Source: =IF(NOT(ISERROR(MATCH(N28,$B$5:$B$8,0))),E5:E6,F5:F6)
 
Upvote 0
Hi, It works. Thanks a lot.

I tried with this below formula, but It doesn't work for me. May I know what is the error in this.


1616561323096.png




=IF(N28=List!$B$5,Table9[SLEEVE],IF(DAMPER!N28=List!$B$10,List!$H$21))
 
Upvote 0
You can't use table names in a Data Validation formula / source.
If you use table names, you need to set up a RangeName with a Refers to being the Table Name or if multiple column the Table Column used for the lookup.

20210320 Index Match Multiple Tables v02.xlsx
ABCDEFGH
1Table Nametbl_TYPEtbl_SLEEVEtbl_OTHERS
2Drop Down List Range Namedd_TYPE (COLUMN 1 ONLY)dd_SLEEVEdd_OTHERS
3Additional Range Namedd_TYPE_LOOKUP (Whole Databody excl Headings)
4TYPEDependant Drop DownSLEEVEOTHERS
5FSDdd_SLEEVEYESNONE
6FDdd_SLEEVENO
7SDdd_SLEEVE
8CDdd_SLEEVE
9LRdd_OTHERS
10ATNdd_OTHERS
11NDdd_OTHERS
12BDdd_OTHERS
13
List


20210320 Index Match Multiple Tables v02.xlsx
MNOP
25
26TYPESLEEVE
27
28LRNONE
29
Sheet1
Cells with Data Validation
CellAllowCriteria
N28List=dd_TYPE
O28List=INDIRECT(VLOOKUP(N28,dd_TYPE_LOOKUP,2,FALSE))


1616585094832.png


1616585243304.png
 
Upvote 0
Hi, Someone replied me this. Seems working. which one is better.

=IF(NOT(ISERROR(MATCH($N28,List!$B$5:$B$8,0))),List!$U$5:$U$6,List!$V$6)
 
Upvote 0
Hi, From your formula. Can you clarify.

1. what is dependent drop down starts from C5, the one with dd_....

2. If possible would you explain the way your formula works in steps. Also can you clarify what this step does in your formula for me to understand N28,dd_TYPE_LOOKUP
 
Upvote 0
Seems working. which one is better.

1. what is dependent drop down starts from C5, the one with dd_....

2. If possible would you explain the way your formula works in steps. Also can you clarify what this step does in your formula for me to understand N28,dd_TYPE_LOOKUP
In the short term what is better is what works for you given where you are on your Excel Journey.

I am not sure this is the place to get into it but I will give it a quick try. In the long term, the aim is to minimise what is "hard coded" in the formula minimising the need to modify or maintain the formula in the future.
You can to this by
  • Replacing constants with cell references or even better range named Cell references
  • Replacing Cell ranges with Table Structured references which auto-expand and contract to fit the content
  • Using vlookup / xlookup etc instead of multiple if then else statements
In the original method:
1) What happens when you have more data in column B ? Then the Data Validation / Drop Down list for TYPE will break, it will continue to only pick up rows 5-12
2) In your logic and formula, you have mixed data in the same TYPE list (Column B). Rows 5 to 8 need the Validation data in Column E and Rows 9 to 12 need the Validation data in Column F (G in my version). What happens when you want the 5-8 rows to be 5-10 ? The formula breaks.

Mitigate by:
1) Adding more data to B
Tables auto expand, so if your formula uses a table structured reference especially for TYPE it will automatically expand and contract.
We only want the data from the body (not the heading) and only the Column called Type so the reference is tbl_TYPE[TYPE].
You can't use that in the Data Validation box so I have created a range name dd_TYPE which refers to tbl_TYPE[TYPE]. (apparently I could have by passed that and used =Indirect(tbl_TYPE[TYPE], in the validation box.

2) Mixed logic in B
My TYPE table consists of 2 columns. Now instead of hard coding that rows 5-8 need different treatment to rows 9-12, you can control that based on what you put in the second column.
So you can add rows, sort rows, change the category of a row, without breaking the formula.
The formula now uses a vlookup to get the value in that 2nd column and uses that value to get Columns E (tbl_SLEEVE via dd_SLEEVE) or Column F (G in my version tbl_OTHERS via dd_OTHERS) for the 2nd Validation List - referred to as a "Dependent Drop Down List"
Using the Table Structured Reference tbl_Type picks up both data columns but for use in the Validation Formula I have mapped that to dd_TYPE_LOOKUP.
The VLOOKUP(N28,dd_TYPE_LOOKUP,2,FALSE), uses the TYPE entered into N28 to get the value in the 2nd column in tbl_Type which in turn gets SLEEVE or OTHERS table for the 2nd Drop Down in O28

Additional resources:
The 1st 8:15 mins of this (Leila Gharani XelPlus) will show you using tables in Validation Lists
SMART Drop Down Lists XelPlus
For Dependent Drop Down Lists using Table (Debra Dalgleish Contextures) - the video is 8 mins - I think I have sent you this before
Dependent Drop Down Lists Contextures
 
Upvote 0
Solution
What about this in O28?

View attachment 35151

Source: =IF(NOT(ISERROR(MATCH(N28,$B$5:$B$8,0))),E5:E6,F5:F6)
Hi, Your formula works well for me. Would you assist what if there is a multiple conditions as explained,

1. If N28 in Sheet1 equals B5 to B6 in Sheet name LIST, Then the output dropdown option at O28 in Sheet1 should be E5.
2. If N28 in Sheet1 equals B7, then the output dropdown at O28 in Sheet1 option should be E5 to E6.
3. If N28 in Sheet 1 equals B8 to B12, then the output dropdown at O28 in Sheet1 option should be F5.

SHEET NAME LIST
Worksheet 3.xlsx
ABCDEFGH
1
2
3
4TYPESLEEVEOTHERS
5FSDYESNONE
6SDNO
7CD
8FD
9LR
10ATN
11ND
12BD
13
14
15
List



SHEET NAME SHEET1

Worksheet 3.xlsx
NO
24
25
26TYPESLEEVE
27
28 ATN
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
O28Cell Valuecontains "NO"textNO
Cells with Data Validation
CellAllowCriteria
N28:N89List=TYPE
 
Upvote 0
What about:
Code:
=IF(OR(N28=B5,N28=B6),E5,IF(N28=B7,E5:E6,IF(OR(N28=B8,N28=B9,N28=B10,N28=B11,N28=B12),F5,"?")))
 
Upvote 0
What about:
Code:
=IF(OR(N28=B5,N28=B6),E5,IF(N28=B7,E5:E6,IF(OR(N28=B8,N28=B9,N28=B10,N28=B11,N28=B12),F5,"?")))
It shows an error. Would you able to include that formula in the excel.
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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