Dynamic Named Range based on second column's value without VBA - excel

I'm trying to build an interface that allows a user to select a category of modification (17 total categories) and have the second drop down box list only those modifications (anywhere from 5-30 modifications) that apply to that category.
Normally, I would set up reference tables to indicate which modifications apply to which category. However, this particular tool is going to have new data populated every week by a non-technical person. There is already a structure in place that will assign each modification number to a given category. However, the list of modification numbers present in any given data pull will change so much that maintaining the separate lists will get overly cumbersome.
My hope is that there is a way to have a dynamic named range contain only those values where the category column is equal to the selected category.
I want to use DNRs because I will be using it as part of a validated data list that will end up controlling the display of a handful of graphs for the end user. Additionally, we aren't allowed to use macros for our shared spreadsheets.
A1 would contain the category (I can get this named range to work just fine, it's a basic one)
A2 should contain only those mods from column C where the corresponding cell in column D equals the value of A1.

You can use a dynamic range name to pull the sub categories if
there is a two-column table with categories in one column and sub categories in the other column
all main categories are repeated (no blanks)
the table is sorted ascending by the main category column.
A dynamic range name can then be built with a formula along the lines of
=INDEX(Sheet1!$B:$B,MATCH(Sheet1!$E$2,Sheet1!$A:$A,0)):INDEX(Sheet1!$B:$B,MATCH(Sheet1!$E$2,Sheet1!$A:$A,1))
So, you only need to work out how to get this two-column table created dynamically from your data entry tool.

I did something similar recently, where the subcategories had to be user-updated. The categories and subcategories are easily updateable and easily understood by the non-technical, the only rule being that you don't leave blanks in the middle of your lists. In my working version, of course, the category table was on a separate "Menu" tab.
This is (a slightly simplified version of) the layout I came up with:
And these are the named ranges in the example:
category is the category cell
cats is the row that holds the list of available categories
DDCats is the list of categories for the drop-down, dropping blanks
mods is the full grid of subcategories/modifications
modlist is the dynamically chosen column of mods, dependent on the chosen category
DDMods is the list of mods for the drop-down, dropping blanks

Related

How can I make a drop down list in Excel 2013 based on several conditions?

What I would like to achieve is that sellers can choose the STORE in the blue cell (either with a drop down list or by hard-typing the STORE name) and, based on the selection on the blue cell, the available POSITIONS for that particular PRODUCT and that particular STORE are show in the green cell as a drop down list.
Let's say I have an Excel workbook, which contains a worksheet with this table with products data, which is automatically imported daily from our Nav server with this layout. It has 4 columns including PRODUCT CODE, DESCRIPTION, STORE IN WHICH IT CAN BE LOCATED and POSITION INSIDE DE STORE (please, check screenshot). It contains 1.5k rows and it changes dynamically, for example, new items are added or positions are exchanged.
As you can see, the same product (PRODUCT 2) can be located in several stores (STORES 1, 2 and 3), and it can be in several locations on each store (POSITIONS 2, 3, 1 and 4).
Now I need sellers to report which of these items they pick and from where, not only the STORE but its POSITION inside the store too. They do it with another worksheet inside the same Excel workbook. It looks more or less like this (please, check screenshot).
I know the drop down list is achieved via Data Validation but I can't figure out the formula for this. I have tried several approaches like:
Array formula to return all POSITIONS in the same ROW, following this (Formula 2.): https://www.ablebits.com/office-addins-blog/2017/02/22/vlookup-multiple-values-excel/. It is quite slow to calculate on the 1.5k items and, once done, I can't figure out how to make Data Validation to look for the 4 or 5 or 10 POSITIONS returned by the array formula, which also need to be filtered by STORE (please, check screenshot for the closest that I have been, array formula returning POSITIONS from column E).
Same formula as above directly on the Data Validation list box, which returns only the first POSITION found.
VBA custom fucntions which are not allowed in the Data Validation box.
I feel comfortable with both Power Query and VBA, and forumla as well, and can adapt most of the code I see but I don't know why I just can't figure out how to achieve this, maybe it is only I am blocked or something but every path I start to follow ends up in a dead end.
Does anyone have an idea on how to approach this? It doesn't really seem that complicated but it is becoming impossible for me.
Thank you very much for your time!!
This is what I have finally done, just in case someone else is facing this situation.
Instead of a plain-text table for the POSITIONS, I created a PowerQuery importing that CSV. Named that worksheet _LOCATIONS.
Added a custom column (Column E) combining the PRODUCT and the STORE so I had something like a Unique Identificator, resulting something like this but in PowerQuery.
Combined column:
Sorted column E and sub-sorted column D, so I make sure the list will always be ordered as I need, and saved the query.
Then, in worksheet REPORT, I entered this formula to create the drop down list in Data Validation in cell D2:
OFFSET(_LOCATIONS!$D$1,MATCH($A2&"-"&$C2,_LOCATIONS!$E:$E,0)-1,0,COUNTIF(_LOCATIONS!$E:$E,$A2&"-"&$C2))
And I am able to choose from the available POSITIONS for the selected PRODUCT in the selected STORE.
Brief explanation:
I set the reference for the OFFSET function in the very first POSITION (D1), and then I move it the amount of rows detected by the MATCH function (which searches for the "PRODUCT 2-STORE 2" string in the newly created combined column) minus 1 (PoweryQuery table has headers) and 0 columns. This leaves me on the first occurrence of my string (but on the POSITIONS column). Then I make the offset as high as the amount of rows detected by the COUNTIF function (which counts all occurrences of my PRODUCT-STORE pair), returning an array of all the positions (column D) matching the PRODUCT-STORE pair.
Ask for formula in Spanish if you need it.

Remove Blanks from cascading (dependent) drop-down list

So I've got a table with two drop-down lists; the first is a drop-down list of categories, the second is a list of projects within those categories. The way it works is simple: you pick a category, and then the second list gives you the appropriate projects. The lists are based on this table:
The problem I'm facing is that the number of projects in each category isn't the same, so while it works fine for categories like Graphic Design (Column D), the list for categories like 3D animation (Column B) are filled with blank spaces.
Is there any simple way of getting rid of the spaces?
Ideally by having excel ignore blanks, because we add new projects from time to time, so Id like the range to stay the same, and not have to fiddle with it too much when adding new projects.
Thanks :)
Here is a simplified illustration on one way to achieve what you want. Note I am applying this in Sheet2.
Let's assume that your lists are in a table called Table1.
Let's assume that your initial dropdown is in E2, and that options must correspond with the header names in Table1.
Firstly we will create a name called DepDD_All, as follows:
=INDEX(Table1,0,MATCH(Sheet2!$E$2,Table1[#Headers],0))
This will generate a sub-list for your dependent dropdown, including blank lines.
To create lists based only on the actual line count, I will use a secondary name, called DepDD_Dyn, as follows:
=INDEX(DepDD_All,1,1):INDEX(DepDD_All,COUNTA(DepDD_All),1)
Reference this name in your dropdown to display only lists with relevant number of items.

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 adding data based on current data

I'm trying to write a macro that i can run which will allow me to simply sort a range of orders into what i like to call categories.
The basic idea is that we get orders through, and we generally have to print a different type of shipping label for the different items, based on weight, size and value. Unfortunately, there is no easy way of doing this other than going through all orders (sometimes thousands) and copying them into different worksheets to group them into the type of shipping method we need to use.
What i'd like to do (i already have a couple of macros already) - is to look in another sheet whereby we store the item titles, and have a second column within that sheet with a number (1, 2 or 3). For each item, based on it's weight, size or value, which we have already specified - they would be assigned a number. The Macro will look at the item name, if the sales sheet finds a match from column A in the item's sheet, it will then add the correct number specified in the item's sheet to the cell next to the item title in the sales sheet.
Column A-G has all customer details, Column H has the item title. The number i'm wanting to add to the row will be inserted into Column I.
The item's sheet has Column A which is the item title, and Column B is the number assigned to this item.
I have tried to muster a macro up myself, however it's confusing me no end.
This is exactly what vlookup is used for
=VLOOKUP(H1, items!A:B,2,FALSE)
Put this formula into I1 on the sales sheet and drag it down, if the items sheet is not in the same workbook , you will need to modify the reference to point to it,
you could obviously write a macro that will insert this formula and drop it down, but it will still be using vlookup or application.vlookup to get the result
Wildcard searches at the front would be
=VLOOKUP("*"&H1, items!A:B,2,FALSE)
or both ends would be
=VLOOKUP("*"&H1&"*", items!A:B,2,FALSE)
NB* BE CAREFUL WITH THIS AS YOU MAY HAVE ITEMS WITH SIMILAR DESCRIPTIONS
like "apple" and "red apple"
you should always use a product code to do lookups when available

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:

Resources