Dropdown list with a conditional statement - excel

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.

Related

Excel Filter formula with named ranges

I'm looking to use the filter formula on a named range but there hasn't been a resource that has explicitly showed how to reference columns within a named range. I might add that the whole named range includes the headers due to the nature of the original data. It has 13 Columns.
The columns I want with their position is: "Injury Date" (6) and "INCURRED" (8)
=filter(Loss_Run,[Insert Chosen Columns Here])
This is the syntax I am trying to use but I cannot get it to work. I am not sure how to tell it to use the columns I want. Do I use the name of the columns or the number either way is fine to me.
I am trying to filter by a specfic value of a row and that is where the main hiccup is.
I got
=FILTER(Loss_Run,(Loss_Columns="Injury Date")+(Loss_Columns="INCURRED"))
to work.
BUT,
I want to first filter the first column, "ULGTACCT Code" (1) by a value (that is in cell A2 for our purposes). It is not allowing me to filter by the first column with or with out the other columns
What I have found says:
=FILTER(Loss_Run,(ULGTACCT Code=$A$2),"")
should work but I get #Name? error.
To answer about calling a column within a table with name ranges and the FILTER function is things are much smoother if you specify columns as =FILTER(TableName[ColumnName],include"argument") within brackets "[ ]", this means that your table will need to be named to make this easier. That's how you would call a specific column.
To the other point of specifying the columns to FILTER, I have only found that to do this you write it as =FILTER(TableName[#[ComlumnName1]:[ColumnName4]],include"argument") and that should do it but I get an #Value error doing that.
I'm looking for any help as well with this so if this helps to bring you to a answer please share.
I was using
=FILTER(TableName, (TableName[Column]="SearchValue")
And I got all table rows back that were matching the criteria.

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.

Excel Formula with OFFSET Fails When Copied to Different Sheet

I've been struggling with this longer than I care to admit, but I have a fairly simple OFFSET function call which works on one sheet, but if I copy it to a different sheet it gives a #VALUE error.
On a sheet named "Deliverable" I have this formula in a cell:
=OFFSET(Deliverable!$B$72,1,0,,3)
and it works fine.
If I go to any other sheet and use the same exact formula, or use it in the Name Manager, it gives a #VALUE error.
If I leave off the final parameter indicated the number of columns I want, it does work:
=OFFSET(Deliverable!$B$72,1,0)
but of course isn't giving me the range I need.
Any idea what's going on with this?
I'm using Excel 2016 on Windows 7.
-- Updated Info --
In a nutshell, my spreadsheet has two cells which I'm using as dropdown lists, where the 2nd cell's list feeds off the selection in the first. The data they are based on has this format:
OptionA A B C D
OptionB A B
OptionC D E F
So the first dropdown uses a simple Data Validation source pointing to the column with OptionA, OptionB, etc. Once that's chosen, the second dropdown list should contain the appropriate options for the one selected. So if OptionB is selected, then the 2nd dropdown list should show A and B.
When I initially wrote this, the data validation source was just a simple VLOOKUP entry, but the lists often had blanks since the number of options varies for each entry. Wanting to fix it up a bit, I ended up with this formula:
=OFFSET(Deliverable!B72,Deliverable!B87,0,1,COUNTA(OFFSET(Deliverable!B72,Deliverable!B87,0,1,5)))
There won't be any more than 5 options, and there are no empty cells in the middle of the data to filter out.
In one spreadsheet I have I used this as a named range definition, then specified the named range for the cells data validation source and it worked. In this other spreadsheet however, it gave me the error described earlier.
However, it looks like when I enter the statement directly into the data validation source field and not in the name manager, it works as expected.
Am I taking the totally wrong approach?
What is it that you want this formula to do? As written, it is returning a block of three horizontal cells. The #VALUE error is Excel's way of telling you "Hey, you're trying to return three cells, but I can't fit them all in the one cell that you are calling this formula from".
The reason you see a result in some places and not others is because of something called Implicit Intersection. Give it a spin on Google. But basically, it just returns whichever one of those three results corresponds to the column that the formula is entered into. If you copy that exact same formula to say row F you will see that it returns a #VALUE error there, because it doesn't know what cell it should return given the column you're calling it from doesn't match any of the cells it is returning. The fact that you don't know this indicates that the formula you're using doesn't in fact do what you think it does.
--UPDATE --
Okay, following your further clarificaiton it seems that you're talking about Cascading Dropdowns aka Dynamic Dropdowns. Lots of info on Google about how to set these up, but you may be interested in an approach I blogged about sometime back that not only provides this functionality, but also ensures that someone can't later on go and change the 'upstream' dropdown without first clearing the 'downstream' one should they want to make a change.
Note that those links talk about a slightly complicated method compared to others, but the method has it's advantages in that it also handles more levels than two, and your DV lists are easily maintained as they live in an Excel Table.
This sounds like an array equation. Try hitting Ctrl+Shift+Enter in the other sheets to validate it as an array equation.
Whenever you need to reference ranges instead of single cells, Excel needs to know that you are working with arrays.

Excel VLOOKUP #N/A

What I am trying to achieve is matching two projects with eachother "Project No" in two tables, and return the "project name" in second table. When I do this I receive this error inside the cell error #N/A.
I have formated both tables into number value, but this does not solve the problem.
Anyone that has an idea what I can do in order to solve this problem.
Here is the first table (just a snapshot to give an idea).
Here is the second table (just a snapshot to give an idea).
The #N/A error indicates that Excel cannot find the value you've specified in the list in which you've told it look. When I run into this, there are a few things I do to troubleshoot:
1) Make sure both columns are in the same format.
You mention you've already done this (good job!) but sometimes formatting gets stuck in Excel. One thing you can do is to highlight each range and use the text to columns feature (under the data tab) to convert it all to the same format. Another option is to copy the range into Notepad or some other plain text editor and then copy it back into Excel to strip out any lingering formatting.
2) Double check your ranges.
Make sure your Vlookup is looking to the correct range, and make sure that range is locked (i.e. $A$1:$D$100 rather than A1:D100), or else your ranges are going to slide around as you move drag the formula down your table. If the range refers explicitly to a table address (e.g. Table1[#All]), then make sure every data point if validly within that table.
3) Make sure the range lookup parameter is set to FALSE
Range lookup is the last parameter of the vlookup, and determines whether the vlookup will find an exact match (set range lookup to FALSE) or a partial match (set range lookup to TRUE). Setting range lookup to TRUE can sometimes create errors like the one you've described. I always set it to FALSE by default unless I need specifically need to set it to TRUE.
4) Use the find and replace window to manually evaluate the formula
If everything looks correct, copy the value you want to look up and paste it into the find and replace window to search for it. If Excel can't find it and you can see it in your list, something is definitely wrong with the formatting or else your file may have some degree of corruption. If Excel can find the value, double check that it is within the range your vlookup is looking through.
If fist table is the one with vlookup formula and second is a source it may mean that such Project No. doesn't exist in your source table. Did you check that possibility?

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