Update dynamic drop-down list in excel without VBA - excel

I want to create 2 dependent drop-down lists in excel, first drop-down value decides what value has to be displayed for the second dropdown.
Used following OFFSET formula for second dropdown values to get populated dynamically.
=OFFSET($B$2,MATCH($G$3,$B$3:$B$17,0),1,COUNTIF($B$3:$B$17,$G$3),1)
. I have also prepared a sample file showcasing the formulas I have used.
When I select first dropdown value, second dropdown list gets updated. BUT, when I select another value in first dropdown, second list doesn't showcase the values immediately.
Sample file link - https://drive.google.com/file/d/1rwt6B-INgrQ0NgxIl-Nc8JeoGziBaiL2/view?usp=sharing

Now that's what I call a challenging request.
We will use the secret Evaluate formula to achieve this.
Disclaimer:
Ensure that a status never get separated from its peers (e.g. do not add another New at the end of the table, rather insert a column so that statuses stay in packs).
Note that changing status will not clear the definition cell. Simple VBA will do the trick (and that is the only place where you will need VBA).
Solution:
Let's create a formula that returns a the address of the range we want to use in the dropdown. You can paste that it I3.
=ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0),0)), COLUMN($C$2)) & ":" & ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0)+COUNTIF($B$3:$B$17,$G3)-1,0)),COLUMN($C$2))
If I made no mistake with my French Excel, you should get the address of all the definitions for the status you put in G3. Extend the formula a few rows down and you will see it always matches G4, G5 and so on.
Time to define a Name (Menu Formula > Name manager > New), that we will call DynamicRange.
First, I would recommend to change the scope to your worksheet (Dropdown in the window).
Next, put the very formula we tried before, but in an EVALUATE.
=EVALUATE(ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0),0)), COLUMN($C$2)) & ":" & ADDRESS(ROW(OFFSET($C$2,MATCH($G3,$B$3:$B$17,0)+COUNTIF($B$3:$B$17,$G3)-1,0)),COLUMN($C$2)))
Here what it looks like (except I'm all in French ...)
Go back to data validation and in the list's source, simply type =DynamicRange
The list is easy to define once the above was done successfully.

I see what you are trying to accomplish (get the second cell value to auto update to the first list entry), but I do not think it is possible without using VBA.
My understanding is that "Data Validation" only verifies the data within the cell, it does not change the existing value.
If you want to change the existing value, then I would look into VBA.

Related

Dropdown list with a conditional statement

I have some materials in column B, a few among these are in a Table definition called Material_List. In D49 I am trying to write a conditional statement such that, if the data in B49 already exists in the table definition, then print the header name or else INDIRECT($49). C49 has the independent dropdown list and D49 will be the dependent.
In D49 I have used the following formula within the Data-->Data Validation-->Source=
=IF(MAX((ISNUMBER(MATCH(Material_List;$B49;0))*COLUMN(Material_List)))=0;
INDIRECT($C49);
INDEX(Material_List[#Headers];1;MAX((ISNUMBER(MATCH(Material_List;$B49;0))*
COLUMN(Material_List))))))
with Allow=List. But it says Error "There is a problem with this formula"
When typed the following formula in cell D50 directly, it works well but obviously without dropdown.
=IF(MAX((ISNUMBER(MATCH(Material_List;$B50;0))*COLUMN(Material_List)))=0;
INDIRECT($C50);
INDEX(Material_List[#Headers];1;MAX((ISNUMBER(MATCH(Material_List;$B50;0))*
COLUMN(Material_List))))))
I am trying to build a dropdown list based on the mentioned criteria. could anyone please tell what is wrong with my formula?
I think the main issue with your formula is that you cannot use table references in the data validation.
Don't ask me why. I think it is just an outstanding Excel bug which hasn't been fixed yet. Please see this link for further info: https://exceloffthegrid.com/using-an-excel-table-within-a-data-validation-list/
The best way I have found to work around this is to create a named range which refers to the table references you need ("Material_List" and "Material_List[#Headers]" in your case). Then you can use those named ranges in your data validation instead of the table references directly.
However, I think there are also other issues with your formula. For example, this part:
MATCH(Material_List;$B50;0)
Normally a MATCH would be in the format of:
MATCH(<single value to look for>, <range to look in>, 0)
You appear to have that reversed, meaning that it should always return a #VALUE! error.
Also, I don't think you can use match on a 2D array, so if your "Material_List" table is more than a single column, that would also cause it to return a #VALUE! error.
UPDATE:
The way I would tackle dependent dropdowns would be as follows.
I would create a "Material_List" table similar to below (could be on a hidden sheet):
Then I would create 3 named ranges.
One for the table body range, called "MaterialList_TblRange":
=Material_List
One for the table header range, called "MaterialList_TblHeaderRange":
=Material_List[#Headers]
And one to refer to the dependant dropdown options, called "DropDownOptions" (this is by far the most complicated part):
=INDEX(MaterialList_TblRange,1,MATCH(Sheet1!$B23,MaterialList_TblHeaderRange,0)):INDEX(MaterialList_TblRange,COUNTA(INDEX(MaterialList_TblRange,1,MATCH(Sheet1!$B23,MaterialList_TblHeaderRange,0)):INDEX(MaterialList_TblRange,ROWS(MaterialList_TblRange),MATCH(Sheet1!$B23,MaterialList_TblHeaderRange,0))),MATCH(Sheet1!$B23,MaterialList_TblHeaderRange,0))
I will explain what this is doing in a moment.
The last step is to set up the data validation where we want our lists.
Where we want the master lists to appear, we can simply enter:
=MaterialList_TblHeaderRange
And the defendant dropdown validation can be entered as:
=DropDownOptions
This is the result:
Now back to the long "DropDownOptions" named range formula...
Basically, we use INDEX:INDEX to select the first/last cell in the range we want to use in out dropdown.
The first INDEX:
=INDEX(MaterialList_TblRange,1,MATCH(Sheet1!$B23,MaterialList_TblHeaderRange,0))
Simply selects the first cell from the column whose header matches the selection in our first dropdown.
The second index does the same, except that instead of selecting the first cell in the column, it counts the number of cells that contain text and uses that as the last cell in the range.
This does mean that we mustn't have any gaps in this table, otherwise an option might be missed off the end.
I hope this makes sense.

Excel Formula too long for Data Validation dropdown list and challenging with Named Range

This is my first my post here, so please correct me where I am not clear with my question.
What do I want
I want to create a dropdown, where in column 'N' I can make a dropdown choice, which limits what I can see in column 'O'.
So, if I choose in column 'N' for 'single_choice', I can only see the options that apply to 'single choice' in column 'O'.
For hours I am trying to get this formula work in Excel "Data Validation" for the list dropdown option.
=IF($N$2="family.single_choice",'Data Formatting'!$N$2:$N$4,
IF($N$2="family.matrix",'Data Formatting'!$N$6:$N$10,
IF($N$2="family.open_ended",'Data Formatting'!$N$11:$N$14,
IF($N$2="family.demographic",'Data Formatting'!$N$15:$N$16,
IF($N$2="family.datetime",'Data Formatting'!$N$17:$N$19,
IF($N$2="family.multiple_choice",'Data Formatting'!$N$5,
IF($N$2="family.presentation",'Data Formatting'!$N$20:$N$21)))))))
To make it a dropdown, I tried to place the formula in 'Data Validation'.
A shorter version of the formula worked fine, but when I tried to paste the entire formula, it became a challenge to paste same in Data Validation.
After some searching through the internet, I learned that 'Data Validation' allows for a maximum of character.
Through below link of someone with the same question, I learned that I could solve the challenge by applying the formula in a 'Named Range' with a 'fix' in Excel.
See below the link that I found and used:
Excel-VBA Assistance - Data Validation too long, need alternative
As below, I placed the formula in a named range called: 'SubtypeFormula" with the 'fix' at the front and end of the formula.
`=IF($N$2="family.single_choice",'Data Formatting'!$N$2:$N$4,
IF($N$2="family.matrix",'Data Formatting'!$N$6:$N$10,
IF($N$2="family.open_ended",'Data Formatting'!$N$11:$N$14,
IF($N$2="family.demographic",'Data Formatting'!$N$15:$N$16,
IF($N$2="family.datetime",'Data Formatting'!$N$17:$N$19,
IF($N$2="family.multiple_choice",'Data Formatting'!$N$5,
IF($N$2="family.presentation",'Data Formatting'!$N$20:$N$21)))))))'
After several tries of adding the formula named 'SubtypeFormula' in Data Validation, I did not manage to get the dropdown option as I wanted. Instead, the exact formula was either shown, or the dropdown was empty.
Unfortunately all my attempts have failed. Please see attached print screen.
Figure 1 ---> this is what I ideally want, but in a dropdown version.
This picture shows the formula in the cell. The formula works in the cell, but it is not a dropdown option.
Figure 2 --> This is what I should do to create the dropdown function, but the formula is too long.
When I placed and used the name of my formula in Data Validation, I don't see the dropdown as intended in figure 1.
Print screens of two figures -

Excel data validation by typing instead of selection

I am struggling with the autocomplete list in my excel document.
I was trying to use the example from OzGrid
https://www.ozgrid.com/Excel/autocomplete-validation.htm
But it seems like this step is not explained well enough.
First of all, I did step one by linking my cells between these 2 sheets.
[![enter image description here][1]][1]
In both "Frontsheet" and "Locality" the list range is from C51 to C67, as per the OzGrid advice.
Next the step with [Dynamic Ranges][2] probably refers to older versions of Excel with traditional menu, where we could select the "Tools" from the bar. Now in Excel 2016 I believe, that it should be like follows:
Formulas - Name manager - New... where we put our name, scope and refers to (range). I have created the Myrange
[![enter image description here][3]][3]
and finally, I put the formula (assuming that the C50 is my dropdown list cell):
=OFFSET(Frontsheet!$C$50,0,0,MATCH("*",Frontsheet!$C$51:$C$67,-1),1)
but I am getting nothing apart of #N/A
I don't know what's next.
I don't want to use VBA this time, because I want to have these lists allocated to the specified cells. I want to search the records by typing not by selecting since I have got them quite a lot. Is it possible?
This question is somewhat a duplicate to the previous ones, which unfortunately didn't bring me the solution.
Excel 2010: how to use autocomplete in validation list
Excel data validation with suggestions/autocomplete
Your formula =OFFSET(Frontsheet!$C$50,0,0,MATCH("*",Frontsheet!$C$51:$C$67,-1),1) shouldn't return anything but #N/A when entered in a cell because it defiens a range which Excel can't display in a single cell. However, you can use it to define a named range and then use that name to define a Data Validation list.
MATCH("*",Frontsheet!$C$51:$C$67,-1) doesn't work reliably if there are numbers in the lookup range. You might replace it with COUNTA(Frontsheet!$C$51:$C$67) which can deal with numbers or text equally well. The difference is that MATCH will produce the entire list, including intervening blanks, while COUNTA will truncate the list at the bottom by as many rows as there are blanks higher up. Either way, one usually avoids blanks in the source for a validation list.
If you want the user to be able to either choose or enter, you must disable Show alert after invalid data is entered on the Error Alert tab of the Data Validation dialog box, where you set up the validation rules.
The OzGrid solution is poorly written and deceptive. It is simply capitalizing on AutoComplete for cell values. There is no magic in linking to another sheet and using offset or in creating a named reference.
All you need to do is add a list of values you intend to use in the column above the column. Avoid empty rows between this list of 'default' values and what you intend to enter.
Skipped rows 'break' AutoComplete for cells.
But can be resolved by adding an adjacent contiguous 'indexing' column.

Data Validation List with formula in the options of the list

I have had a search around for this and cant find anything or maybe I can't find the right terms to search for.
My problem: Currently my drop down options (in cell drop down) are listed as follows
"PASSED,FAILED,NOT APPLICABLE,NOT TESTED,See Section X,—"
When "See Section X" is selected I would like a formula to populate X with the cell immediately to the right
In VBA you would write something like below but a validation list does not take this.
"PASSED,FAILED,NOT APPLICABLE,NOT TESTED,See Section " & cells(current_row,current_col +1).value & ",—"
In the column to the right I would put a second dropdown with "A,B,C" and then the "See Section X" option would read "See Section "
Any ideas or links that might help me come up with an appropriate solution?
Create a list and define your data validation to use that list (I'm only talking about the 2nd list). In the last cell in this list you would reference the cell where your first selection is located. Something like:
="See Section "&$a$1
Assuming the first data validation is happening in in $a$1.
Each time the first drop down is used, the values for the 2nd will be updated. No code necessary, just a simple concatenation formula at the bottom of your list.

Excel table default value and data validation without VBA

I have a table in Excel for tracking projects. Whenever I create a new row for the table I'd like it to auto-populate one column that the project has "Not Invoiced". I would ALSO like that this column use Data Validation to only allow either "Not Invoiced" or "Invoiced" as content.
I have been able to make both of these things work, but I cannot seem to make them work together without error! The closest I have gotten:
Put a formula in the relevant column. Have tried both the super basic ="Not Invoiced" as well as an =IF formula based on the blankness of another column. This correctly carries down each time I make a new row.
I then add Data Validation on the column which also works fine at first since my default value from my formula is one of the options, HOWEVER when the project does invoice and I select "Invoiced" I then get an error that I'm violating the above formula. From what I've read selecting something from the drop down should just replace the auto-populated formula, but that doesn't seem to happen, it gives me an error that I've violating the column's formula instead.
I've read multiple places that if you correctly order things (create table, add formula for default value, then add data validation) the above method should work, but it will not for me and I continue to get the error every time I change to "Invoiced".
you can enter the stati "Not Invoiced" and "Invoiced" into cells that are close together, e.g. $G$3 and $G$4. Then, create a named range for $G$3:$G$4, let's say "ValList" (menu: Formula / Define Name).
Imagine column A to be the controlling column, and B the status column ("Invoiced" / "Not Invoiced"). Example for cell B5:
The initial status is =IF(A5=""; ""; $G$3)
The Validation (type "List") must be controlled by a formula =IF(A5=""; " "; ValList)
Good luck!
There's a simple way to do this.
Before you start using a new table, add list data validation to the cell in the first and only row:
Invoiced,Not Invoiced
Then, in the first row of your table in that same cell write:
=IF(TRUE,"Not Invoiced";"Not Invoiced")
This will put Not Invoiced as the default value on every new row that is added to the table and also keep data validation in place. You will still have access on every new row's cell to the dropdown list stored in the initial cell's data validation list parameter.
For some reason, data validation is overwritten if you try the same IF-function approach in reference to another cell, as you described it.
One way to solve this would be to use a helper column.
You can use the data validation list for the entry column, say column A.
You can use a formula in the hidden column B with the formula =IF(A1,"Invoiced","Invoiced","Not invoiced")

Resources