Related
I'm trying to create a dropdown menu in excel which eliminates values once they have been selected.
Let's assume that the dropdown offers the values 1...10. If I select 1 in the first dropdown, then the other dropdowns needs to offer only 2...10. Likewise, if I picked to, the the other should offer only 1,3,4,5,6,7,8,9,10.
Basically we want managers to rank their employees based on the performance value.
But if they rate everyone a 4, we need a ranking - but we then dont want them ranking everyone as 1.
I tried with IF statements, but we can have rankings of up to 100 people, so it was becoming a nightmare.
Not sure if I am clear?
Any help would be appreciated.
You can use data validation custom formula to avoid duplicates. It would not be a dropdown but it would work exactly as you wish:
In my example, I've selected range B2:B5 and then I applied a data validation custom formula like this:
=COUNTIFS($B$2:$B$5;B2)=1
You can even customize the error message:
With that formula, any entered value will be accepted exactly once. If it's used again, it will raise an error.
Notice I can't type a second time the value 1 because it's been already used.
You can do this by creating a helper table which lists all the valid ranks and whether or not they have been used yet. This can be on the same sheet or another, hidden sheet if you prefer:
The formula in the "Used?" column is a simply counts the number of times that rank appears in the "Rank" column and checks if it is greater than 0 - returning TRUE or FALSE:
=COUNTIFS($B$2:$B$11,$H2)>0
The "Remaining Ranks" column then uses this in a MINIFS formula to remove the used ranks:
= MINIFS(
$H$2:$H$11,
$H$2:$H$11,">"&MAX($K$1:$K1),
$I$2:$I$11,FALSE
)
This is saying to select the lowest number from the "All Ranks" column, where the rank hasn't already been listed in the "Remaining Ranks" column AND the "Used?" column is FALSE.
This will result in zeros at then bottom of the "Remaining Ranks", so we can wrap it in an if statement to replace the zeros with an empty string "":
=IF(
MINIFS($H$2:$H$11,$H$2:$H$11,">"&MAX($K$1:$K1), $I$2:$I$11,FALSE)=0,
"",
MINIFS($H$2:$H$11,$H$2:$H$11,">"&MAX($K$1:$K1),$I$2:$I$11,FALSE)
)
You can now use the "Remaining Ranks" column as your source for the data validation list, and it will update as the ranks are entered.
This will result in some blank options at the bottom of the list.
If these are an issue for you, they can be removed by using an INDEX formula in a named range. Let me know if you would like me to explain how that can be done.
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 was building a financial model and ran into this problem. Cell C2 contains the dropdown list and the value E25 changes according to the dropdown list. What I want is for the present value column in K22:K25 to change automatically. FOr example, if I choose normal in the dropdown list, I want the value of E25 to update automatically in K22. Thanks in advance!
You might use a formula like this in K22:K24.
=Index($J$22:$J$24, MATCH($C$2, $I$22:$I$24, 0), 1)
This will give you one of the values in J22:J24, depending upon what was chosen in C2. I presume you would want to multiply that value with something. That might be a value you extract from another range using a similar function.
J22:J24 must contain the same values as the dropdown. Normally, you would do all of this with named ranges and use the same named range to feed the dropdown as you use for determining the choice the user made.
Try the MATCH function independently to get a better feel for it.
= MATCH($C$2, $I$22:$I$24, 0)
It will return a number between 1 and 3, depending on the choice in A3.
I know the data validation only lets you place 255 characters. I have named cells/ranges as I have several list I'm trying to pull or select certain information from based on a criteria.
My formula is as follows:
=IF(AND(RETAILER="",DISPLAY_TYPE=""),"",IF(AND(RETAILER=CODES!$F$2,(OR(DISPLAY_TYPE=CODES!$V$1,DISPLAY_TYPE=CODES!$Y$1))),CODES!$V$2:$V$49,IF(AND(RETAILER=CODE S!$F$2,(OR(DISPLAY_TYPE=CODES!$AB$1,DISPLAY_TYPE=CODES!$AE$1))),CODES!$AB$2:$AB$94,IF(AND(RETAILER=CODES!$F$3,(OR(DISPLA Y_TYPE=CODES!C1,DISPLAY_TYPE=CODES!C2,DISPLAY_TYPE=CODES!C3,DISPLAY_TYPE=CODES!C4))),"INCORRECT COMBINATION, Correct Retailer or Display Type",IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AH1),CODES!AH2:AH38,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AJ1),CO DES!AJ2:AJ10,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AL1),CODES!AL2:AL18,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=C ODES!AN1),CODES!AN2:AN18,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AP1),CODES!AP2:AP18,IF(AND(RETAILER=CODES!$F$3,DI SPLAY_TYPE=CODES!AR1),CODES!AR2:AR29,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AT1),CODES!AT2:AT29,IF(AND(RETAILER=C ODES!$F$2,(OR(DISPLAY_TYPE=CODES!C5,DISPLAY_TYPE=CODES!C6,DISPLAY_TYPE=CODES!C7,DISPLAY_TYPE=CODES!C8,DISPLAY_TYPE=CODES !C9,DISPLAY_TYPE=CODES!C10,DISPLAY_TYPE=CODES!C11))),"INCORRECT COMBINATION, Change Retailer or Display Type",""))))))))))))
I know, too long for data validation, so, I then tried to "name" my formula by choosing a cell where my formula is nested (hit CTRL+F3, named the cell CHECK_FORMULA) and placed the above formula in the "refers to" box. Then, I went to C21 (where I want to have my data validation) and entered the following:
=IF(OR(RETAILER="",DISPLAY_TYPE=""),"INVALID",CHECK_FORMULA)
The error that I receive, " The list source must be a delimited list, or reference to a single row or column". The formula provides a set list of parts depending on the criteria set that will show. I didn't have this issue when the formula was under 255 characters, chose the list according to criteria, no problem, but now, because other list were added, I'm having this issue. Is there a macro I can put this into in order to accomplish my goal? or can I use CASE in a way to get what I'm trying to accomplish?
I think that data validation does not play nice with named ranges.
Try using the INDIRECT formula.
=IF(OR(INDIRECT("RETAILER")="",INDIRECT("DISPLAY_TYPE")=""),"INVALID",INDIRECT("CHECK_FORMULA"))
SOLVED....I placed the formula in a named range and it worked after I applied a "fix" to my Excel (issued by Microsoft): The name range 'CheckFormula' works with the following:
=`IF(AND(RETAILER="",DISPLAY_TYPE=""),"",IF(AND(RETAILER=CODES!$F$2,(OR(DISPLAY_TYPE=CODES!$V$1,DISPLAY_TYPE=CODES!$Y$1))),CODES!$V$2:$V$47,IF(AND(RETAILER=CODES!$F$2,(OR(DISPLAY_TYPE=CODES!$AB$1,DISPLAY_TYPE=CODES!$AE$1))),CODES!$AB$2:$AB$72,IF(AND(RETAILER=CODES!$F$3,(OR(DISPLAY_TYPE=CODES!C1048575,DISPLAY_TYPE=CODES!C1048576,DISPLAY_TYPE=CODES!C1,DISPLAY_TYPE=CODES!C2))),"INCORRECT COMBINATION, Correct Retailer or Display Type",IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AH1048575),CODES!AH1048576:AH36,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AJ1048575),CODES!AJ1048576:AJ8,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AL1048575),CODES!AL1048576:AL16,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AN1048575),CODES!AN1048576:AN16,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AP1048575),CODES!AP1048576:AP16,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AR1048575),CODES!AR1048576:AR27,IF(AND(RETAILER=CODES!$F$3,DISPLAY_TYPE=CODES!AT1048575),CODES!AT1048576:AT27,IF(AND(RETAILER=CODES!$F$2,(OR(DISPLAY_TYPE=CODES!C3,DISPLAY_TYPE=CODES!C4,DISPLAY_TYPE=CODES!C5,DISPLAY_TYPE=CODES!C6,DISPLAY_TYPE=CODES!C7,DISPLAY_TYPE=CODES!C8,DISPLAY_TYPE=CODES!C9))),"INCORRECT COMBINATION, Change Retailer or Display Type",""))))))))))))`
Thank you to all those who provided assistance.
I have three columns in my Excel file that are currently being AutoFiltered. I've been tasked with setting up multiple filters. The way I began was to build a 'menu' of choices using ActiveX checkboxes and assigning the 'Linked Cell' property to a cell way out to the right. So, if the first option is checked, cell BB30 says 'TRUE'.
The issue starts with the fact that the first column has 16 items, the second column has 11 items and the 3rd column has 5. The way my boss wants it to work is if they select 2 options from column 1 and one item from column 2, it filters the data (on a separate sheet) on that information.
Example data:
Column A Column B Column C
-------- -------- --------
aCol1 bCol1 cCol1
aCol2 bCol2 cCol2
aCol3 bCol3 cCol3
aCol4 bCol4 cCol4
aCol5 bCol5 cCol5
aCol6 bCol6
aCol7 bCol7
aCol8 bCol8
etc. etc.
So, if I select aCol1, aCol2, and bCol3 -- we want to filter (ACOL1='TRUE' OR ACOL2='TRUE') AND BCOL3='TRUE' to then filter the data.
I did some searching and it seems using SELECT CASE is the way to go but this would give me more than 800 different scenarios... not to mention if nothing from a certain column is selected (only aCol1 and bCol8 selected, for example).
Is there a better way to do this?
If I have to write a separate CASE statement for each scenario, will Excel 2010 handle that many?
Finally, once I've determined what all has been selected, how do I write the VBA so that it actually DOES this?
Don't write a select block.
What you want to do is to iterate through each column and if the value is true then add an autofilter with the related value. You do this for each column and that will filter as you want to do it.
As for how to accomplish this using VBA, you can simply use the range and call the AutoFilter() method with the value to filter for. I assume you have minimal knowledge of VBA.
Range("A1:Dx").AutoFilter Field:=x, Value:=x