Hello wonderful people.
I have a series of named ranges, A_Colours, B_Colours, etc.
These represent sections of a sorted column in a colour list, sorted by codes for the manufacturer that makes those colours. These are dynamic named ranges, constructed by COUNTA for how many colours have that mfr code. By my calculation, the list should be contiguous, since the column is sorted by code.
I know I can reference the ranges in Data Validation by simply setting =A_Colours as the list source (no quotes). This does work in this case.
However, I have a dropdown to control which A-M range I want to show in the child dropdown.
So, e.g. dropdown in A1 shows A, B, C, D as options.
Dropdown in B1 shows dropdown options relative to the chosen option in A1.
EXAMPLE:
I select A from the list in A1.
In cell B1, I want my dropdown to show all values from named range A_Colours.
I have tried all manner of ways to pass the text string A_Colours to the DV list source field, but all have failed. Either error in formula, or the range evaluates to an error, or it allows me to select only A_Colours from the dropdown.
Example 1:
A1 choose A
B1 DV box:
=INDIRECT("$A$1")&"_Colours"
This gives error "The list source must be a delimited list, or a reference to single row or column."
Could this be because the table list is sorted? I don't think so because the very first example above works.
Example 2: use helper cell in C1 to create text string "A_Colours", by formula:
=$A$1&"_Colours"
Then in DV box for cell B1:
=INDIRECT("$C$1")
Please help me achieve this!
Thank you.
[Edit] SOLUTION:
Create new sheet as directed below.
Create header for each manufacturer ("A" in cell A1).
Enter formula into A2 (as an array formula, Ctrl+Shift+Enter):
=INDEX(Colours, SMALL(IF((INDEX(Colours, , 1)=INDEX(MFR,MATCH(A$1,MFR[MFRName],0),2)), MATCH(ROW(Colours), ROW(Colours)), ""), ROWS($B$1:B1)), COLUMNS($A$1:$B1))
I adapted it a bit, but credit for this goes to https://www.get-digital-help.com/2009/09/28/extract-all-rows-from-a-range-that-meet-criteria-in-one-column-in-excel/
Apply the formula down to the last plus a few to allow for expansion.
Apply the formula across to your last header.
Now you have lists which are definitely contiguous and single-column and not dynamic, so meet the stringent criteria for data validation.
Create a named range for each list, using the exact name keeps it simple but I chose to add "Name" to the end, e.g. Mfr1Colours.
Reference them in the DV source list field (for cell B2 in our original sheet) like:
=INDIRECT($B$2&"Colours")
What this does:
Looks in the Colours table:
MFR Code Colour Code
Finds the first matching instance of the MFR Code in cell A1 of our original sheet ("A") from the Manufacturer table "MFR", which has columns:
MFRName Code
Pulls out the row by the MATCH(ROW(Colours,Row(Colours),"").
Checks which row and column you want by the ROWS and COLUMNS at the end.
If you have a spare, helper range, where you would make a simple codetable with 2 columns - Color_Reference, Color_Names and name it c_colors:
A A_Colour
B B_Colour
C C_Colour
You could use this in CV list configuration for dropdoon on cell B1:
=INDIRECT(VLOOKUP(A1;c_colors;2;FALSE))
Try to look at the examples here, it may help you as well: http://www.contextures.com/xlDataVal02.html
Related
I have a list of items in column A and for some of the items, column B has value "Y". How do I only include the items of column A marked with "Y" in a data validation list?
I have tried this in the data validation formula but doesn't seem to work:
INDEX('Mysheet'!$A$8:$A$240,SUMPRODUCT(--('Mysheet'!$B$8:$B$240="Y")))
If you have Excel 2016+ with the FILTER function, you can
Enter this formula someplace on the worksheet: =INDEX(FILTER(A1:B10,B1:B10="y"),0,1)
Create a dynamic name definition. For example:
myList refers to: =OFFSET(Sheet1!$D$1,1,0,COUNTA(Sheet1!$D:$D)-1)
You can then use a Validation formula for the List:
=myList
If you don't have the FILTER function, you can use this formula:
=IFERROR(INDEX($A$1:$A$10,AGGREGATE(15,6,1/($B$1:$B$10="y")*ROW($B$1:$B$10),ROWS($1:1))),"")
and fill down until you get blanks, or at least as far as you might have y's in column B.
Then for the formula name (which has to be a bit different because of the blanks in the list):
refers to: =OFFSET(Sheet1!$F$1,1,0,SUM(--(LEN(Sheet1!$F:$F)>0))-1)
How do I find either the cell address or preferably the row and column of the value 119, or any other number in the table below?
The table does not contain row or column titles, only the numbers as shown.
I am looking for a worksheet solution (formula) and not a VBA solution.
An Array Formula
This is an array formula and it has to be entered with control shift enter i.e. hold control shift and then press enter.
=MAX(IF(A1:J34=119,ROW(A1:J34)-ROW(A1)+1))
Remarks:
The value is searched by column i.e. A1, A2, ... B1, B2 ... i.e. if you had another 119 in cell D1 the result would still be 2, and if you had a 119 in cell c1 then the result would be
1.
For a column version just replace ROW with COLUMN:
=MAX(IF(A1:J34=119,COLUMN(A1:J34)-COLUMN(A1)+1))
Well, clunky and you can expand it, but it does work:
Row is separate to column but you could put them together in one cell, does depend on how you want to use the results, but you did not specify that so I have done this...
You could use a choose() function or a lookup table with vlookup() to change the column result to a letter...
Please try:
=MOD((K1-50),34)+1&" | "&1+(INT((K1-50)/34))
where K1 is your selected value.
Returns R | C. (Data in A1:J34 is not required.)
Below is a general purpose answer based on VBasic2008's answer.
I modified the formulas to utilize defined names so that the cell references do not have to be hard coded in the formulas. This way both the data table and row / column formulas can be relocated to anywhere on the spreadsheet. It works for both numerical AND text based data.
I also included the =ADDRESS() function to return the absolute reference of the look up value.
For illustration purposes, a step by step example for Data Set 1 is shown replacing the hard coded cell references with defined names.
The Data Set 2 section is the simplified version just using one defined for each the row and column look up value.
You can download an example spreadsheet here: Look_Up_a_Value_in_a_Table.xls
Thanks to all of you: Solar Mike, VBasic2008, and pnuts
Click on the image to enlarge.
I have write below array formula:
=INDEX(Table1[Column2],SMALL(IF(Sheet1!G6=Table1[Column1],ROW(Table1[Column1])-ROW(Table1[[#Headers],[Column1]])),ROW($A:$A)))
According this picture1:
Note that selected range contains above array formula.
I need define that array formula returned values in the list form of data validation for Column2 of right table.
What I had tried:
I defined a Name, because responsively Sheet1!G6 reference part of above formula have change in Column2 cells for its appropriated Column1 cell. (in right table), according to below picture2:
Then set Column2 of right table's data validation, (picture3 below):
The problem is
But in result, validation list only contains first result of array formula! as picture4 below:
Question
How can define an array formula valued results set to a Name (Picture 2 above) and use in List Data Validation (picture 3 above) for a Column of table ? (Picture 4 above)
My concepts are:
There where a array form formula as shown above. (On the paper and
not in a worksheets range, yet)
This array formula is corresponding to a set -collection- of (potentially returned) results.
I want use above set in the Data-Validaton List for a special Table column.
Not using helper things (as Sheet, Column, Pivot-table and Etc...)
Using (1)- Name (Ctrl + F3), (2)- the array formula (for generating valid results collection), and (3)- Data-Validation List (to check is entered value in above special Table column is valid or not valid; and let entering only valid data in that special column))
I know you said you don't want to use a helper column or sheet. But saying:
A Table and an array formula can't coexist.
Data validation source can't be a complex formula of any kind, but you can use Indirect to a named range or address (but only if its a continuous region, not multiple areas) on the source formula if you want.
An array is never returned as a whole result in array formula, each cell used on as target destiny of the calculation is an item of the returned array.
So what I would do, return the array formula in a region let's Say A1, and a counter to the number of items in your array result that are valid using another cell B1. Use a cell C1 to determine the address of the list that you want to use. Then use =INDIRECT(C1) in the source of your validation.
You can hide other sheet so another use can't see it, and if you hide it by macro you can set it to very hidden and it's not possible to make it visible from the workbook directly. You might also create a named range to the C1 cell in my example so the end user can't see where this source on validation is from.
Im trying for some hours already to split a text cell into a usable object to the validation list.
The cells today are populated by 3 or more (N) comma (I can change that to semicolons, pipes...) separated values like "1,2,3" or "5,test,8,new"
I want to transform that into a validation list with N different values.
In the following post there is a formula that splits a string into and array, but I have not managed to use it as source:
Split a string (cell) in Excel without VBA (e.g. for array formula)
Is it possible to create a Dynamic Range from splitting the cell text and feeding it into a 'combobox' (validation list).
Another similar example of what I am looking for but without VBA:
Excel Dynamic Drop Down Using Comma Delimited Data
What am I doing wrong here? Thanks for reading this far.
You can do this by
Use a formula to break up the comma separated list into separate cells
Then use dynamic range names to refer to the DV List
Formula
to return an array in the sequence of {1,99,198,297, ...}
Create a defined name formula: (Formulas --> define name)
seq_99 Refers To: =IF(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))=1,1,(ROW(INDEX($1:$65535,1,1):INDEX($1:$65535,255,1))-1)*99)
With your lists in row 1 on some worksheet, use the following formula:
A2: =INDEX(TRIM(MID(SUBSTITUTE(A$1,",",REPT(" ",99)),seq_99,99)),ROWS($1:1))
and fill down as far as needed to account for your longest list. I assumed A2:A10 would be sufficient.
Next, create dynamic named formulas to refer to just the portion of each list that contains data.
Example:
dvList1 Refers to: =OFFSET(Sheet2!$A$1,1,0,COUNTA(Sheet2!$A$1:$A$10)-COUNTBLANK(Sheet2!$A$1:$A$10)-1)
Format your DataValidation cell as a List with the named formula:
The list will now show the non-blank entries.
It is possible to formulate this using Find. To split the text in cell "A1", the formula will be:
1st part - cell B1 formula:
=LEFT(A1,FIND(",",A1)-1)
2nd part - cell C1 formula:
=MID(A1,FIND(",",A1)+1,FIND(",",A1,FIND(",",A1)+1)-FIND(",",A1)-1)
3rd part - cell D1 formula:
=MID(A1,FIND(",",A1,FIND(",",A1)+1)+1,999999)
Then a list validation may be added to Cell E1, with the range B1:D1
I'm using the INDIRECT function to create a dropdown list in a cell. The contents of the list will depend on what is chosen in the previous column (same row).
e.g. if in Column A "Cuisine" I have three options in the list (Italian, Chinese, British), I want Column B "Dish" to reflect what was chosen in col A.
So if I chose "Italian" the list in col B will be "Pizza, Lasagne, Macaroni"
I've defined names on a separate sheet and I can get this all working by using the function INDIRECT($A$1) in the data validation command for the cell and using choose from a List.
However when I move to the next row, I want the same functionality. Is there way to reference the active row - something like INDIRECT ($A$ActiveCell.Row)??
Assuming cells in column A has a list of "Cuisine Types", for each of this "Cuisine Types" there is also a Defined Name containing the corresponding options for each "Cuisine Type". With a formula in Column B you want to retrieve the corresponding options for each "Cuisine Types".
Try this formula in cell B1 then copy till last record:
=INDIRECT( A1 )