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")
Related
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.
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.
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.
My Table A list which grows on data refresh is as follows:
Balham Halfords - P83690
Balham Halfords - P83690
Gloucester & Durham St - P83680
Gloucester & Durham St - P83680
In another sheet, I want data validation on the drop down list to show only:
Balham Halfords - P83690
Gloucester & Durham St - P83680
The trouble is, I don't want to create a distinct list off Table A anywhere in the book, and I want the data validation list to be intelligent to new records coming into to Table A.
If you want to use Helper column approach with formula, try this solution.
if your data is in column A, enter this formula =IFERROR(INDEX($A$2:$A$900, MATCH(0,COUNTIF($D$1:D1, $A$2:$A$900), 0)),"") in cell D2 and drag it down as long as you estimate there will be distinct values. You must enter it using CTRL+SHIFT+ENTER since it is an array formula.
Then use data validation, select list and under source enter this formula =OFFSET(D2,0,0,198-COUNTBLANK(D2:D200),1)
Now whenever new values are added to table, they are also automatically added to your data validation list.
#DasalKalubowila, here is a modification on #KresimirL's answer that may be what you're looking for.
First, create a defined name for your input data. Do this by going to Formulas on the ribbon and then clicking Name Manager under the Defined Names group.
In my example, I called the input data range InputData. The formula I used is
=Sheet1!$A$2:INDEX(Sheet1!$A$2:$A$501,MATCH("Ω",Sheet1!$A$2:$A$501))
where
Sheet1 is the name of the worksheet where the input data lives,
$A$2 is the first cell containing data in your input range (I call this the anchor),
$A$2:$A$501 is the max area of the column where your data either lives and could potentially live in the future, and
"Ω" is the Omega letter. You can get this by holding down ALT and pressing 2 then 3 then 4 on the 10-key number pad (it can also be found in the character map application in Windows).
This formula effectively grows or shrinks your range of data based on how many entries exist.
Next, you need to create a helper column. I know this wasn't desired, but it's going to be one of the only/better ways out there. I placed mine on the same worksheet as my Input Data, but you don't have to. The formula I used in E2 is
=IFERROR(INDEX(InputData,MATCH(0,COUNTIF($E$1:$E1,InputData),0)),"")
You'll need to commit this with Ctrl+Shift+Enter as it's an array formula. Then drag that formula down as far as you to. You'll basically want to go down as many rows as you think you'll have unique entries.
I then needed to create one more defined name, which is what will be used under my Data Validation in the next step. I called this new defined name ValidationList (this needs to be scoped to the Workbook). The formula I used for ValidationList is
=Sheet1!$E$2:INDEX(Sheet1!$E$2:$E$501,COUNTIF(Sheet1!$E$2:$E$501,">*"))
See the notes for InputData above to understand this formula better. The only difference is that instead of MATCH, this formula uses COUNTIF. This is because if your unique values don't yet fill the entire range you dragged your formula down in Column E (in the previous step), using MATCH in the same way was before would end up grabbing a whole bunch of blanks we don't want. COUNTIF therefore only counts those cells that contain a value greater than "*", with asterisk being a wildcard for any character (and "" contains no characters, so it excludes those items).
Now, create your data validation and set it up like such:
Now you should be left with this:
And when you add information to your InputData area, your range of ValidationList should expand to include the newest uniques, which in turn will populate inside your Data Validation area, like such:
I find that this doesn't seem to slow my workbooks down too significantly, but I'd be interested in hearing how it performs in yours.
I am trying to change the Master Key to a “new key” if the origin and destination match the old key.
Basically the master key from table 1 will look to see if the key exsists in Table 2, if it does it will pull the new Key. If the master key does not exist in Table 2 it will not change. It will be the original origin and destination.
I have tried using if statements with vlookups however I am getting stumped with the logical error. Does anyone know how to return the new value or if there is another way to solve this?
I have attached an example.
In the example, in table 1 the Master key is made from London and Italy together. This master key needs to be looked up in Table 2 (located in Column A) If it’s there it will pull the New Key (Column D).
Try this formula in D2 of Sheet1 and drag it down,
=IFERROR(VLOOKUP(A2,Sheet2!A:F,4,FALSE),A2)
I would use an Index/Match solution rather than a vLookup. vLookup is great for simple tasks, but it doesn't usually work whenever you try to do anything more complicated. I now find it is a simpler solution almost everytime (though I am not sure how it compares in performance).
Try something like this in your table1 cell D2:
=IFERROR(INDEX(Sheet2!$A$2:$F$4,MATCH(Sheet1!A2,Sheet2!$A2:$A4,0),4),Sheet1!A2)
What this will do is starting with the Match portion:
It will check the list in Sheet2 A2:A4 for a match of the same string as in Sheet1 cell A2. If it finds it, it will return a row number, if not it will return an error.
Next, the INDEX takes your second table as a source, and uses the row number determined in the Match and the fourth column (which is column D), and returns that value. If the Match returns an error, this will also return an error.
So, we use the IFERROR to capture the situation where the MasterKey in Table 1 does not exist in table 2. In that situation, I am assuming you just want to keep the same MasterKey from Table 1, but you can change that to anything you like.
If that works, you simply drag the formula down from Sheet1!D2 down to Sheet1!D4. Also, if your Table2 is much bigger then you have shown, you will need to adjust the Index and Match inputs to reference the correct range size. Keep in mind the use of "$" as they will prevent the formula from changing those cells when you drag it down.