To create dynamic dropdown list in excel 2013 - excel

I have one sheet containing the table name customer_id and Project_id.For each customer id various projects are displayed.when i try to create data validation by selecting all those it is not coming.for ex.
Customer_id Project_id
1 1.1
1 1.2
2 2.2
2 2.3
and like that.please tell me some solution.

This really depends on what you want exactly, but since your question is not that elaborate, I guess you mean this?
You can create a data validator from data in your worksheet in the following way:
Select the sheet you want the validator to be on
In the ribbon, click the data tab, and then Data validation
Select 'Allow List'
in the Source bar, select the cells with the allowed values
Another way, is to create a data validator using a vba or vb.net macro. In your macro say:
Dim range as Excel.Range = listSheet.Range("A1")
range.Validation.Add(Excel.xlDVType.xlValidateList, Excel.xlDVAlertStyle.xlValidAlertInformation, Excel.xlFormatConditionOperator.xlEqual, "Option1; Option2")

I guess what you want are two dropdown lists, the second depending on the value selected in the first one? (please elaborate your questions some more). To do that, I suppose there are other ways but this is what I usually do:
Take into account that I always use names to refer to ranges instead of references, to improve readness. If you have doubts to do it, read Use names in Excel formuas
Create a table or range somewhere in your book with one column with the master values.
I have named the range with the values master_list
Create a table or range somewhere in your book with two columns. The first column contains the master/look-up value and the second the dependent values.
I have named the list of look-up values (this is, the values in the first column) as dependent_list
I have named heading to the cell above the dependent_list (for example, if the dependency table starts in A2, the heading is A1
Order the lists
The master_list is ordered as you wish values appear in the dropdown list.
The dependent_list must be ordered by the values in the first column (master values). It doesn't matter if the order is the same in the master_list and the dependent_list, but identical values in the master column of the dependent_list must be together.
The order in the second column of the dependent_list will determine the order in the dependent dropdown list.
Optionally you can define a message to display in the dependent_list when there is no master value selected. I have named it msg_error.
Click on the cell where you want the master dropdown, ant go to the Data Validation menu, where you select:
Allow: List
Source: Add the formula =INDIRECT("master_list")
I have named the cell where the master dropdown list as key_value
Click on the cell where you want the dependent dropdown, and then go to the Data Validation menu, where you select:
Allow: List
Source: Add the formula =IF(key_value="";msg_error;OFFSET(heading;MATCH(key_value;dependent_list;0);1;COUNTIF(dependent_list;key_value);1))
Note that Excel functions are language dependent of the language and I have translated them to English, so maybe there are mistakes.

Related

Excel Help: Dynamic range + Data Validation

I got a problem with some popular Excel question, dynamic ranges and data validation drop-downs and auto-populate. Lets say I got 2 sheets, and on one sheet I got drop-downs to choose from another sheet, and that is not a problem when I define cells and range using:
=OFFSET($A$19;;;COUNTA('0528 - info'!$E$2))
..but what about when I wanna add some new cells in between,so that they can be automatically recognized in which group they belong:
As you see for instance Column B has some "groups" where you can find more different "values" like in Column C, like Power Supply has MV1 and MV2... and so on. My drop-downs on the sheet 1 are called exactly like this "groups" and I did reference them manually using given function. But is it possible to populate my drop-downs automatically when I add for instance MV3 beneath MV2 in this table? Or RN7 on 14th row? Everytime I add new values I have to extend my dropdowns (what is fine..), but problem will be when I share this table to others, they gonna forget it 90%.
I hope you get my point, any suggest will be fine!
p.s. Indirect doesnt work in a way it should - It gives me all instances from the Column but not specific ones that I need.
=INDIRECT("Table4[VarEDS]")
Well this option gave me again what I already had before - all "matches" from the Column and still not ONLY matches that are for certain group. ...
If your Data Validation source is a "Table" as shown in your image then you can take advantage of "Table Column" Range which is dynamic. That means whenever you refer that column as NAMED range and if make changes to the column (Edit, Add, Delete) it will reflect in the referred cell.
You can use this technique even for ranges not in table. You need to NAME them with offset formula and make dynamic.
You can find dynamic address of your column as shown in the image below. Select entire column WITHOUT Header
Name your column data range with appropriate name as shown in image below
Then in Data Validation Window refer this name using F3 as shown in image below.
Then you can see... Even if you edit, add or delete any row in the column the data validation will change
Editing based on your comment below: If you want text from column B and Column C appear together in the validation dropdown list. Insert column in the table and join text from column B and C and then make data validation based on that column as shown in Colum D in image below
Finally I think I understood your question.
Watch this video
Excel: Find Multiple Matches & Dependent Drop Down List
After some days of searching and trying I got what I wanted - wasnt wasy job at all. Needed to combine more functions with the help of couple of videos from Leyla (Xelplus):
https://www.youtube.com/watch?v=gu4xJWAIal8
https://www.youtube.com/watch?v=7fYlWeMQ6L8&t=5s
First step was to make unique list of my values (text in my case) on separate sheet:
=IFERROR(INDEX(t_VarGroup[Vargrouptext];MATCH(0;INDEX(COUNTIF($J$2:J2;t_VarGroup[Vargrouptext]););0));"")
Then I needed to "extract" all the values that are belonging to the certain unique values:
=#IF($I3<COLUMNS($K$2:K$2);"";INDEX(t_EDS[[VarEDS]:[VarEDS]];AGGREGATE(15;3;(t_VarGroup[[Vargrouptext]:[Vargrouptext]]=$J3)/(t_VarGroup[[Vargrouptext]:[Vargrouptext]]=$J3)*(ROW(t_VarGroup[Vargrouptext])-ROW(t_VarGroup[[#Headers];[Vargrouptext]]));COLUMNS($K$2:K$2))))
FUrthermore, I created Unique drop down list:
=OFFSET($J$3;;;COUNTIF($J$3:$J$14;"?*"))
And then dependent drop down list nearby using:
=OFFSET($K$2;MATCH($H$2;$J$3:$J$17;0);;1;COUNTIF(OFFSET($K$2;MATCH($H$2;$J$3:$J$17;0);;1;20);"?*"))
And because I made it on other sheet, I had to reference them to an appropriate sheet name where my main sheet is - with drop downs, it is actually very useful for my future work and for everyone else who has struggling with drop downs but on a bit specific way =))
credits to: #Naresh Bhople for suggestion about Youtube videos.

Excel VBA Drop Down List with dependent list with multiple selection

I have a spreadsheet where clients have to make Drop Down selections for (1) Account, (2) Account Name and (3) Account Categories throughout excel and are dependent of each other. I actually did a non-VBA Drop Down List dependent of each other. The problem is that the drop down list only works one at a time instead of making multiple selections.
So what I want of course is the drop down list to work for not just one row, but selections of many rows.
The only way this Drop Down List would work non-VBA is by creating as my many Unique List depending on the number of accounts and their dependents.
So far without using Excel VBA I have done the following:
I have Defined Name the 3 Main List ranges: GLacct,GLname, & GLcat:
Created - 3 Unique List:
So this Unique List is populated when the first DDL "55700" is selected, next DDL will populate "Research - Other" and then the next DDL will populate 3 choices correspondent to "Research -Other".
So to create the Unique List in excel I added these formulas:
UniqueGLacct: `INDEX(GLacct,MATCH(0,COUNTIF($F$1:F1,GLacct),0))`
UniqueGLname:
`INDEX(GLname,MATCH(0,COUNTIF($G$1:G1,GLname)+(GLacct<>TM!$A$16),0))`
UniqueGLcat:
`INDEX(GLcat,MATCH(0,COUNTIF($H$1:H1,GLcat)+(GLacct<>TM!$A$16)+(GLname<>TM!$B$16),0))`
Name Manager – Refers to and added the following formulas:
GLacct: Offset(TB!$A$2,0,0,COUNTA(TB!$A$2:$A$1000))
GLname: Offset(TB!$B$2,0,0,COUNTA(TB!$B$2:$B$1000))
GLcat: Offset(TB!$C$2,0,0,COUNTA(TB!$C$2:$C$1000))
uniqueGLacct: OFFSET(TB!$F$2,0,0,COUNT(IF(TB!$F$2:$F$1000=””,””,1)),1)
uniqueGLname: OFFSET(TB!$G$2,0,0,COUNT(IF(TB!$G$2:$G$1000=””,””,1)),1)
uniqueGLcat: OFFSET(TB!$H$2,0,0,COUNT(IF(TB!$H$2:$H$1000=””,””,1)),1)
Added the Data Validation to cells that need the drop down list in Sheet named ™: ( The problem is if I where to make another selection in the next row, I still get the data from the first selection, which means in order to work I have to make as many Unique List for each account.
cell: A16: uniqueGLacct
cell: B16: uniqueGLname
cell: C16: uniqueGLcat
How would I make this Excel Drop Down List dynamic for 3 List dependent for multiple selections using Excel VBA. But if you notice accounts below 55700 can't popular their dependent list because the first selection made is 55700.
The only way this would work without using VBA is by creating Unique List for each account dependent.
I'm not sure you can't do this without a macro.
1) First you could change your reference style to R1C1:
Link to great explanation
2) Then you would create a named range for each unique list (I am assuming they are finite).
3) Then you would add validation List and then Indirect to an name of that range (in the header or an offset cell) to each indirect.
With this, you can just say "This Row, Column offset" or whatever is applicable:
In this case I selected the same row, one column to the left which is the name of the named range that I wanted in the drop down.
The benefit of this is that you have 1 formula across all of your cells. You can change the display back to A1 type display and the formulas will adapt.

Excel formulas and conditional lookups based on multiple criteria and sheets

I have 2 sheets:
sheet_a is a styled print-ready layout for a single data record
sheet_b is a bulk data table which is continually growing. Each row corresponds to a single complete record
Currently I am using a VLOOKUP to collect the data from sheet_b and put it in the respective cells in sheet_a. I have a drop down list on sheet_a which allows me to select a single record at a time to view.
Now I want to introduce a second drop down list to sheet_a where I want to select 1 of 4 specific conditions relating to the value of a cell in a specific column of each record on sheet_b.
I only want the entries that meet this condition in sheet_b to be made available in the range of records I can view on sheet_a.
Can anyone help?
As I understand it, you are looking for a way to filter the list that is used in the drop-down on Sheet_A.
add a column to the source data and calculate or mark manually which of the four conditions the record belongs to.
on Sheet_a add a drop-down field where the user can select from the four conditions. Name this cell "criterion"
in the source data table, add a column with a formula that returns the row number if the current row matches the selected criterion. Something like this copied down
=IF(B2=criterion,ROW(),"")
create another helper column that contains only the items that match the criterion using a formula like this and copied down
=INDEX(Data,SMALL($E$2:$E$18,ROW(A1)))
use a dynamic range name called "FilteredList" that contains only the values of the result list, not the errors. The formula for "FilteredList" is
=Sheet1!$F$2:INDEX(Sheet1!$F:$F,MATCH("zzzzz",Sheet1!$F:$F,1))
change the drop-down that is currently used to select a record to source its values from =FilteredList

Advanced Dynamic Validation Lists in Excel

While a number of other posts address similar issues, I was unable to find one that met my specific needs, using multiple sheets, etc.
What I need is the ability to select a value from a validation list in one column, and then have a second validation list be narrowed to just the values that can be selected based on the first validation list, and then a third that follows the same logic, etc.
So for example, I have 5 sheets:
Log - This sheet is used for input and will contain the columns that
have the dropdown validation lists.
Clients - This sheet is a two column list of clients. Column A has
the Client ID, column B has the Client Name.
Matters - This sheet is a three column list of Matters. Column A has
a Client ID, Column B has the Matter ID, column C has the Matter
Name.
Timekeepers - This sheet is a two column list of Timekeepers. Column
A has the Timekeeper ID, Column B has the Timekeeper Name.
Rates - This sheet is a three column list of Rates. Column A has a
Matter ID, Column B has a Timekeeper ID, Column C has a Numeric
Rate.
The log sheet:
Column A (Timekeeper) will be a simple validation list dropdown from which I will select a timekeeper (by name). This validation list is populated by the list on the Timekeeper sheet.
Column B (Client) will be another simple validation list dropdown from which I will select (by name) a client. This validation list is populated by the list on the Clients Sheet.
Column C (Matter) will have a validation list of Matters. This is the first dynamic validation list, as the list should only show the matters that belong the to client that was selected in Column B. We know which matters belong to a client by the Column A (Client ID) in the Matters sheet.
Column D (Rate) will simply display the rate for a given timekeeper/matter combination. We would now have the matter id and client id from the input into columns A and C, so we just need to locate the row in the Rates sheet that has that matter id and timekeeper id.
The solution can use VBScript or not, whatever you prefer. I'm a software developer, so I'm comfortable with VBScript, and I'm relatively familiar with Excel, so nested built in functions would be fine too.
Thanks in advance!
EDIT:
This workbook is going to be dynamically generated from a database, so I need to utilize an approach that can be generated programmatically.
The "Log" sheet will contain many rows where the user will select a Timekeeper from a dropdown, then select the Client from a dropdown (which will limit the Matter dropdown list) then select a matter from the Matter dropdown (which, combined with the selection in the timekeeper field will determine the "Rate").
The dropdowns will show the "name" values (i.e. timekeeper name, client name, matter name) but the limitations to subsequent lists based on these selections has to be based on the "ID" value for the selected "Name".
An example showing how to use subsequent list limitations would be most helpful. All of the examples I have seen show how to select one value and limit a second list, but I need to be able to have the selection from the second list limit a third list, the third list limit a fourth list, and finally, the "rate" is determined by what is selected in two of the lists.
The gist of dynamic validations is using =INDIRECT(SomeNamedRange) as the Source data in the List type of Data Validation.
Now, the hardest part is to dynamically generate this list of partners. For the sake of this example, I'll assume you have three sheets: Sheet1, Config, and Validation. I'm also assuming you are selecting a Partner based on a Region, as that is a simpler example.
Let's start with Validation.
Here's an example of my data:
Notice how I've sorted the data based on the most general criteria (Region, in this case). This will be important later on. Also notice that I've named A1:A26 as Validation.Region. I've also named B1:B26 as Validation.Partner.
Config is where your magic happens.
Moving over to the Config, we're going to need to add a list of unique regions, and an address describing where they're located. We'll name this address Region.Choices.
For this example, I used the COUNTIF function to find the last partner in the list. The exact formula was ="Config!$B$2:"&CELL("address";OFFSET(B$2;COUNTIF(B$2:B$230;"?*")-1;0)). Unfortunately, Excel doesn't have a built-in function for the sheet's name, so I had to hardcode that. I went ahead and hardcoded $B$2 to improve performance (maybe?), but you could do that dynamically too.
Sheet1 is where you'll be making your dynamic selection.
In this sheet, we have the following structure.
Take B4, name it "Region.Selected", and add Data Validation as a List of Source =INDIRECT(Region.Choices).
Creating the logic behind the dynamic drill down
Now go to Config, and replicate the contents of B1 on C1, making sure to alter the hardcoded $B$2). Finally, name Partner.Choices, and type in the following Array Formula in C2:C100:
=IF(Region.Selected="";OFFSET(Validation.Partner;1;0;COUNTA(Validation.Partner);1);OFFSET(Validation.Region;MATCH(Region.Selected;Validation.Region;0)-1;1;COUNTIF(Validation.Region;Region.Selected)))
Note: to add an Array Formula, select C2:C100 before typing the formula, and once you're done typing, hit Ctrl+Shift+Enter instead of Enter.
While it may seem convoluted at first, this is basically returning every Partner if no Region is selected, or returning the partners from a selected Region by calculating where it ends and starts and shifting one column to the right with OFFSET.
Wrapping up the dynamic drill down
Now go back to Sheet1, take C4, name it "Partner.Selected" (for consistency), and add Data Validation as a List of Source =INDIRECT(Partner.Choices), as displayed below:
For this example, I used the COUNTIF function to find the last partner in the list. The exact formula was ="Config!$C$2:"&CELL("address";OFFSET(C$2;COUNTIF(C$2:C$230;"?*")-1;0)). Unfortunately, Excel doesn't have a built-in function for the sheet's name, so I had to hardcode that. I went ahead and hardcoded $C$2 to improve performance, but you could do that dynamically too.
Now go ahead and test your dynamic validation! It should look like this:

Excel Data Validation List using formula with filtering

I have following workbook:
Worksheet Accounts:
Worksheet Posts:
I would like to know if it is possible to define Data Validation of type List to entire column B in sheet Posts using formula, so that Data Validation popup shows only Account Ids from Accounts sheet which Website column matches Website column of a selected row in Posts sheet and which have value Active in Status column?
In SQL-ish or LINQ-ish words:
SELECT Id FROM Accounts WHERE Website =
#SelectedPostRow.Website AND Status = Active
Marks on the second image shows which values should be shown in a drop-down.
Yes you can do this, but it requires some supporting setup.
First for each of your website options, you need to create a named range for the options that would be in the drop down you are seeking to create.
To do this, just highlight the list of cells and right click, the choose Name a Range
Then you need to create a lookup list for your website names to the named range possiblities
Then in your data validation source use a forumla like this:
=indirect(vlookup(a1,$i$8:$j$13,2,false))
then whala, the dropdown list changes based upon the website value.
Now if you are also needing to automate the named range bits, you could change them to encompass entire columns and then use a pivot table to pull in the data. Would just need
an independant pivot for each website option.
Each time you pulled in fresh data you would need to refresh the pivots, but it would function.
This problem need a bit of a preparation.
In the same sheet, or in another, copy your data (or add the relevant cells)
In column A you have a number that could be ranked.
I obtained it with (cell A2):
=IF(C2=$J$2,1,0)*IF(E2="Active",1,0)*ROW()
In column B rank the number and exclude the unwanted rows (B2):
=IF(A2=0,0,RANK(A2,A:A))
Then you can VLOOKUP in column H, using a enum in column G (manually entered). The formula for H1:
=IFERROR(VLOOKUP(G2,$B$2:$D$9,3,FALSE),"")
Now you could set your validation based on column H
PS: there could be small errors in the formulas as I have translated them from italian and I cannot test in english.

Resources