Related
I need to populate a dropdown on sheet1 with data from sheet2 columnA. I can do this no problem. However, I only want the items from columnA to appear in the sheet1 dropdown if sheet2 columnB has an 'x'.
Screenshots/here refer (updates marked *):
Demonstration
Only values 1-10 have corresponding 'x' in 'col B' (here, d:d), whereas 101-112 correspond to 'y'. Output as follows:
Assuming you have Office 365 compatible version of Excel,
Lookup for validation list (F3#)
=SORT(UNIQUE(FILTER(C3:C41,--ISNUMBER(SEARCH("x",D3:D41)))))
(easily customisable for different range cols A, B - sheet_2)
Validation list
Reference lookup range directly (*updated thanks to note by #Harun24HR)
=F3#
Extras
If interested, a unique list of omitted values (cols A & B, sheet_2) can be determined in a similar yet dependent fashion (cf. first equation):
=SORT(UNIQUE(FILTER(C3:C41,--NOT(ISNUMBER(MATCH(C3:C41,F3#,0))))))
You can just use INDIRECT in the data validation statement that refers to a cell with an IF statement.
For example, in the below picture, my dropdown is based on the formula =INDIRECT($G$9) and the value of G9 is determined by =IF(ISNUMBER(MATCH("x", H3:H7,0)), "G3:G7", "G8")
More generally, just use =IF(ISNUMBER(MATCH("x", test_range)), drop_down_range, empty_cell) and be sure to use quotes around the dropdown range.
Test 1:
Test 2:
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)
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
I have 4 criteria lists that look like this:
A B
Name Category
Name Category
Name Category
And a MasterList like this:
A B
stuffNAME Category
NAMEstuff Category
NAME Category
I would like to know if there is a formula that can search through each criteria list based on the MasterlistA column for "NAME" and return the appropriate "Category" in MasterlistB.
As an example:
I'm looking to return MasterlistB based on MasterlistA
Criteria List:
A B
NBC NBCU
Disney ABC
Masterlist:
A B
NYC NBC 20998 NBCU
NJ2987 NBC NBCU
Disney Florida99 ABC
I'm simplifying, but in reality the criteria lists all refer to different masterlist columns as well. Trying to get the matching/searching part down first.
Given a setup as shown in #ScottCraner 's answer:
In cell E1 and copied down:
=IFERROR(LOOKUP(1,1/COUNTIF(D1,"*"&$A$1:$A$2&"*"),$B$1:$B$2),"No Match")
This is a regular formula and does not require array entry.
You can do this using VLOOKUP, nested with the IFERROR statement.
I am assuming each table is starting on A1, in sheets called Sheet1, Sheet2, Sheet3, and Sheet4. You may need to adjust references to point to appropriate tables.
The basic formula to find the category which matches your name, is simply [assuming your search term is on a new sheet on A1, let's say Sheet5, with the rest of your final data table]:
=VLOOKUP(A1,'Sheet1'!A:B,2,0)
This simply takes the value in A1 [the search term], tries to find it in column A of sheet 1, and if it does find it, takes the first matching row, and returns the value on the 2nd column in [column B, with the category].
If that fails, you simply put that inside of IFERROR, which attempts to calculate something, and if it creates an error, returns something else, like so:
=IFERROR(VLOOKUP(A1,'Sheet1'!A:B,2,0),"NO MATCH FOUND")
Now to use the IFERRORS to first attempt to find a match on Sheet1, then Sheet2, etc., put the following:
=IFERROR(VLOOKUP(A1,'Sheet1'!A:B,2,0),IFERROR(VLOOKUP(A1,'Sheet2'!A:B,2,0),IFERROR(VLOOKUP(A1,'Sheet3'!A:B,2,0),VLOOKUP(A1,'Sheet4'!A:B,2,0))))
To search for only a partial match, you can use the following:
=VLOOKUP("*"&A1&"*",'Sheet1'!A:B,2,0)
The "*" act like wildcards, and if they are included in front of and behind your search term [in this case, A1], then anything that contains your search term, regardless of its position in a cell, will be considered a match. You can replace A1 in all of my above formulas with this revised wildcard match to check for partial matches in any of your sheets.
To search a list of items, which exactly match a part of your search term
You could probably do this with an array formula, but because you have multiple data tables, I think the easiest solution is to use a helper column next to each of those tables, to create a unique ID which actually matches to your Master List. ie:
On Sheet1 [and all other category sheets], insert a new column in between A & B; this column will trace back from column A, to match a Name from your Master List on Sheet5, like so [starting in B1 & copied down]:
=VLOOKUP("*"&A1&"*", 'Sheet5'!A:A, 1, 0)
Your revised formula in your master sheet would now look like this:
=IFERROR(VLOOKUP(A1,'Sheet1'!B:C,2,0),IFERROR(VLOOKUP(A1,'Sheet2'!B:C,2,0),IFERROR(VLOOKUP(A1,'Sheet3'!B:C,2,0),VLOOKUP(A1,'Sheet4'!B:C,2,0))))
Rather than placing the four lists side-by-side like:
Stack them on top of each other like:
The its as simple as:
=VLOOKUP("David",A1:B12,2)
So here is the basic formula to get what you want:
=INDEX($B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & $A$1:$A$2 & "*",D1))),1))
if you have 2010 or later. If you have 2007 and earlier than you will need to use the following array formula:
=INDEX($B$1:$B$2,SMALL(IF(ISNUMBER(SEARCH("*" & $A$1:$A$2 & "*",D1)),ROW($1:$2)),1))
It being an array formula it must be confirmed with Ctrl-Shift-Enter.
In the picture, the first formula is Column F, the second in Column E
You will need to add nested IFERROR() Functions for the various sheets.
=IFERROR(INDEX(Sheet1!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet1!$A$1:$A$2 & "*",A1))),1)),IFERROR(INDEX(Sheet2!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet2!$A$1:$A$2 & "*",A1))),1)),IFERROR(INDEX(Sheet3!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet3!$A$1:$A$2 & "*",A1))),1)),IFERROR(INDEX(Sheet4!$B$1:$B$2,AGGREGATE(15,6,ROW($1:$2)/(ISNUMBER(SEARCH("*" & Sheet4!$A$1:$A$2 & "*",A1))),1)),"NOT HERE"))))
I am going crazy over this. It seems so simple yet I can't figure this out. I have two worksheets. First worksheet is my data. Second is like an answer key. Upon checking checking, A1:B1 in Sheet 1 is a match with the conditions in Row 52 in SHEET 2, therefore, the value in Column C is "MGC". What is the formula that will perform this function? It's really hard to explain without the data so I pasted a link of the sample spreadsheet. Thank you so much in advance.
sample spreadsheet here. https://docs.google.com/spreadsheets/d/1_AjuNfCdGfEM-XkqPa6W4hSIxQg4NM2Vg4c2C1pQ_vQ/edit?usp=sharing
screenshot here. (wont let me post i have no reputation)
In Sheet2, insert a column in front of Column A and put the formula in A2 =C2&D2.
Then in Sheet1, Cell C2 the formula =vlookup(A2&B2,Sheet2!A:B,2,0).
the first make a concatenated key to lookup, then the second looks up that key.
How about a index(match())? If I've understood correctly you need to match across both the A and B column in sheet one, checking for the relevant values in B and C on sheet 2 to retrun worksheet 2 column a to worksheet 1 column c.
third version try:
=INDEX(Sheet2!$C$1:$C$360,MATCH(Sheet1!A1&Sheet1!B1,Sheet2!$B$1:$B$360&Sheet2!$C$1:$C$360,0))
Basically what this does is use concatenation, the & operator, to specify you are looking for "Criteria A" & "Criteria B" in sheet 1, which makes the string "Criteria A Criteria B", which is supplied in the first part of the match function.
In the second it then says match this against all of my variables in sheet 2 in the same way with concantenation.
The final part of match function (0) specifies you want an 'exact' match
It then supplied this as a reference to the index function, which then finds the row intersecting with the value you want, and returns that.
As noted here https://support.microsoft.com/en-us/kb/59482 this is an array formula, so it behaves differently, and must be input differently. https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
There are (at least) 2 ways you could do this without VBA.
USING A SORTED LIST
The first relies on the assumption that your data can be re-sorted, so that everything "Unreported" is in the top, and everything "reported" is together below that (or vice versa). Assuming that this is the case (and it appears to already be sorted like this),we will use the function OFFSET to create a new range which shows only the values that align with either being "Unreported" or "Reported".
Offset takes a given reference to a point on a sheet, and then moves down/up & left/right to see what reference you want to return. Then, it returns a range of cells of a given height, and a given width. Here, we will want to start on Sheet2 at the top left, moving down until we find the term "Unreported" or "Reported". Once that term is found, we will want to move one column to the right (to pull column B from sheet 2), and then have a 'height' of as many rows as there are "unreported" or "reported" cells. This will look as follows in A1 on sheet 1, copied down:
=OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),1)
This says: First, start at cell A1 on sheet2. Then find the term in A1 (either "unreported" or "reported", on sheet2!A:A (we subtract 1 because OFFSET starts at A1 - so if your data starts at A1 we need to actually stay at "0". If you have headers on sheet2, you will not need this -1). Then, move 1 column to the right. Go down the rows for as many times as Sheet2 column A has the term found in Sheet1 A1. Stay 1 column wide. Together, this will leave you with a single range on sheet2, showing column B for the entire length that column A matches your term in sheet1 A1.
Now we need to take that OFFSET, and use it to find out when the term in Sheet1 B1 is matched in Sheet2 column B. This will work as follows:
=MATCH(B1,[FORMULA ABOVE],0)
This shows the number of rows down, starting at the special OFFSET array created above, that the term from B1 is matched in column B from sheet2. To use this information to pull the result from column C on sheet 2, we can use the INDEX function, like so:
=INDEX([FORMULA ABOVE],MATCH(B1,[FORMULA ABOVE],0))
Because this would be fairly convoluted to have in a single cell, we can simplify this by using VLOOKUP, which will only require the OFFSET function to be entered a single time. This will work as follows:
=VLOOKUP(B1,[FORMULA ABOVE],2,0)
This takes the OFFSET formula above, finds the matching term in B1, and moves to the 2nd column to get the value from column C in sheet2. Because we are going to use VLOOKUP, the offset formula above will need to be adjusted to provide 2 columns of data instead of 1. Together, this will look as follows:
FINAL FORMULA FOR SHEET1, C1 & COPIED DOWN
=VLOOKUP(B1,OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),2),2,0)
OPTION USING ARRAY FORMULAS
The above method will only work if your data is sorted so that the REPORTED and UNREPORTED rows are grouped together. If they cannot be sorted, you can use an ARRAY FORMULA, which essentially takes a formula which would normal apply to a single cell, and runs it over an entire range of cells. It returns an array of results, which must be reduced down to a single value. A basic array formula looks like this [assume for this example that A1 = 1, A2 = 2...A5 = 5]:
=IF(A1:A5>3,A1:A5,"")
Confirm this (and all array functions) by pressing CTRL + SHIFT + ENTER, instead of just ENTER. This looks at each cell from A1:A5, and if the value is bigger than 3, it gives the number from that cell - otherwise, it returns "". In this case, the result would be the array {"";"";"";4;5}. To get the single total of 9, wrap that in a SUM function:
=SUM(IF(A1:A5>3,A1:A5,""))
In your case, we will want to use an array formula to see what row in Sheet2 matches A1 from Sheet1, and B1 from Sheet1. This will look like this:
=IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW($B$1:$B$100),""),"")
This checks which rows in column A from sheet 2 match A1. For those that do, it then checks which rows in column B from sheet 2 match B1. For those, it pulls the row number from that match. Everything else returns "". Assuming no duplicates, there should only 1 row number which gets returned. To pull that number from the array of results, wrap the whole thing in a MATCH function. Now that you have the row number, you can use an INDEX function to pull the result in Column C with that row, like this:
FINAL ARRAY FORMULA METHOD
=INDEX($C$1:$C$100,MAX(IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW(Sheet2!$B$1:$B$100),""),"")))
Remember to confirm with CTRL + SHIFT + ENTER instead of just ENTER, when you type this formula. Note that I didn't refer to all of Sheet2!A:A, because array formulas run very slowly over large ranges.
The following formula should work without making any changes to the datasheets.
=INDEX(Sheet2!$A$1:$A$360,MATCH(Sheet1!A1,IF(Sheet2!$C$1:$C$360=Sheet1!B1,Sheet2!$B$1:$B$360),0))
Remember to save this formula as an array with CTRL+SHIFT+ENTER
Documentation on how to use INDEX and MATCH against multiple criteria can be found on Microsoft Support.
It's not clear what you want to do with the multiples that do not have corresponding matches. txed is listed as Unreported twice in Sheet1; kntyctap is listed as Unreported three times. There are only one corresponding match on Sheet2 for each of these.
Non-array Standard Formulas for multiple criteria matches
For Excel 2010 and above use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999,AGGREGATE(15,6,ROW(1:999)/((Sheet2!$B$1:$B$999=A2)*(Sheet2!$C$1:$C$999=B1)), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
For version of Excel prior to 2010 use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999, SMALL(INDEX(ROW($1:$999)+((Sheet2!$B$1:$B$999<>A1)+(Sheet2!$C$1:$C$999<>B1))*1E+99, , ), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
I've handled error with the IFERROR function in that latter formula. Excel 2003 and previous may have to use an IF(ISERROR(..., ...)) combination.