Excel-VBA Assistance - Data Validation too long, need alternative - excel

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.

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.

Matching text to named range and returning named range approximate match

Looking to figure out how to automate a Model Number matching search and return.
Searching an "Order Report"(sheet1) cell that when the value is partially reduced will be a match for a model value where the range is named (model_list) and my goal is to return that match.
Example
Sheet 1 cell A3 is the location of the Order Report model number
ex: 12-TH512-100E
Sheet 3 range G3:G100 is the named range "model_list"
ex: TH510, TH512, TH514, TH516, TH518, TH520
Use a formula in Sheet 2 to find the model_list match and return its value
ex: TH512
My only attempts and research so far has been on finding a way to use vlookup or index-match but I haven't been able to make either work how I am intending.
The purpose of all this is to avoid the need of manual data entry when processing a customer order into our manufacturing documentation.
Try this Array Formula:
=INDEX(model_list,MIN(IF(ISNUMBER(SEARCH("*-"&model_list&"-*",'Sheet1'!A3)),ROW(INDIRECT("1:"&COUNTA(model_list))))))
Being an array, it must be confirmed with Ctrl-Shift-Enter, instead of Enter when leaving edit mode.
The following picture is only to show it works, I put everything on one page.

Excel: Show matching content in cell

A bit of a noob with Excel. I’m trying to help my department by making an assignment front sheet that will insert data based on the selections made.
So far I have created a drop down list that will check for unit number (data validation -> list -> named range), which in turn adds the unit name (index and match named ranges) and shows only available criteria linked to that unit (data validation -> list -> indirect). The problem that I am having is getting the criteria descriptor to show up in the cell next to the chosen criteria.
I don't want to be using VBA or any macros as the staff and IT Techs are paranoid about security. A formula based solution would be great.
It probably makes more sense if you download(updated link) my spreadsheet.
Thanks
AC
I Think your actually looking for this
=INDEX(Unit1_Criteria_Descriptor,MATCH($C17,INDIRECT(SUBSTITUTE($J$7," ",""),0)))
Your unit in C17 has a space "Unit 2" so i am using SUBSTITUTE to remove before i pass it to INDIRECT so that the MATCH is looking up the right column
If I've understood the data in your sheet correctly, you can use a VLOOKUP
In Cell D17: =IF(ISBLANK(C17)=FALSE,VLOOKUP(C17,Data!$L$2:$M$14,2,FALSE))
In Cell D18: =IF(ISBLANK(C18)=FALSE,VLOOKUP(C18,Data!$L$2:$M$14,2,FALSE))
In Cell D19: =IF(ISBLANK(C19)=FALSE,VLOOKUP(C19,Data!$L$2:$M$14,2,FALSE))
etc.. for as many rows you have.
I'm not sure if the extra columns are meant to be populated too using the data in your data sheet, but its fairly simple to adjust the VLOOKUP to do this.
Update
My code above doesn't work as I didn't look at the validation stuff. I've edited your example work book, and it should now display the correct details.
The colours in the data sheet are just to show the name'd ranges I've used.
https://dl.dropboxusercontent.com/u/10316127/2015-Assignment_.xlsx

Resources