As you know Excel only lets you use one lookup value, but I need to compare three lookup values to find a fourth value.
For example in the screenshot below I want to use the information name, pet and business to find who the teacher is on the second sheet. For the record this is just example data to understand how to perform the task and I need to apply this to over 600 rows!
First sheet:
Here is the first sheet
Second sheet:
Here is my second sheet
Edit: I keep getting an error when I try to enter this formula: =index(Sheet2!A2:G7,MATCH(Sheet1!A5&Sheet!C5&Sheet1!D5,Sheet2!B2:B7&Sheet2!D2:D7&Sheet2!E2:E7,0))
Instead of Vlookup(), you can use Index/Match, which is a nice alternative that lets you do this.
The formula correctly returns "Miss Smith":
Note: This is entered as an array formula with CTRL+SHIFT+ENTER
So, the basic layout of the formula is:
=Index([range to return],match([single look up value],[range where that value would be],0))
You can combine lookup values by concatenating them, as you can see in the screenshot. So, the single lookup values are A2, C2, and D2. And, you'd expect to find "Sarah" in the range G2:G3, "Dog" in H2:H3, etc.
Please let me know if I can clarify anything.
Edit: To help visualize the two sheets thing. I put the table (which you will lookup from) on a sheet called "Data Sheet". The table we need to complete is on "Main WS".
Here's "Main WS":
and the "Data Sheet":
Given the cyclic calulation and disregard for the Worksheet.UsedRange property that the AGGREGATE function exhibits, you will want to cut down the ranges for the lookups to the minimmum required. Pick a column that will typically determine the extent of the lookup range and use that to define the end point of each lookup column.
Sheet2:
Sheet1:
The formula in Sheet1!E2 is,
Fill down as necessary.
Related
I need to categorize data: I have a column with the description of the element I'm interested in. I want to check that description for a keyword, then check if that keyword is contained in for example column A of a separate table. If a match is found, I need returned the value in the next column (in this example column B) of the same separate table.
The attached screenshot shows how the data is organized. The column called Column1 is the output I need.
I have actually found a solution, but it involves lots of nesting, I need to force the categories and keywords in the formula and I can't add all the conditions I need; this is the current formula:
=IFERROR(IF(SEARCH("keyword";cellWithDescription);"category";);"OTHER")
And for more categories I repeat the formula instead of "OTHER":
=IFERROR(IF(SEARCH("keyword";cellWithDescription);"category";);IFERROR(IF(SEARCH("keyword2";cellWithDescription2);"category2";);"OTHER"))
which is not ideal, especially with many categories. How can I accomplish the same task with a simpler and more efficient formula, possibly comparing the keyword to values in a table (and not inside the formula itself, as I did now)?
Thanks in advance for your help!
This works for me
=INDEX(category,MATCH(1,--ISNUMBER(SEARCH(keyword,cellWithDescription)),0),1)
enter as array formula, thus ctrl+shift+enter after copying the formula (curly brackets will appear around the formula)
I want to write a function similar to simple Index-Match or Vlookup-Match.
Problem:
The values of the "Kadabra" columns should be shown in the "Jam" column and the "Shadabra" column in the "Jim" column. Given that the Columns will have consistent headers(Jim, Jam, Kadabra, Shadabra) but their positions may change(which means we cannot use column numbers).
"Abra" and "Jimmy" are the index values.
I'm looking for an excel formula solution. If there isn't one then a Visual Basic solution is also welcome.
One way to achieve this would be to use an Index Match Match formula as below, if you were to enter this formula into cell B8:
=INDEX($A$1:$C$4,MATCH(A8,$A$1:$A$4,0),MATCH("Kadabra",$1:$1,0))
And in C8:
=INDEX($A$1:$C$4,MATCH(A8,$A$1:$A$4,0),MATCH("Shadabra",$1:$1,0))
Then you could fill the formula down and it should bring the appropriate values into your Jimmy/Jim/Jam Table.
First please check below screenshot:
I have created a match table at E:F in order to avoid nested IFs for that condition. You may move the match table to another sheet and change your formula accordingly.
Formula for B8 is as below. You may drag-copy it down and right:
=VLOOKUP($A8,$A$2:$C$4,MATCH(VLOOKUP(B$7,$E:$F,2,0),$A$1:$C$1,0),0)
Instead of writing the formula multiple times at multiple instances, I'd like excel to detect the formula based on a defined reference.
Column F should be calculated based on the Operation defined in column E. In this example, I can use IF() as I only have 4 Operations but this question is linked to another scenario where I have over 20 Operations.
I have all the formula's ready but I'd love to understand if there is way to use the appropriate formula based on "Operation" Column.
I would approach your situation by labeling your Column A, B, C, or X, Y, Z or something similar for consistent readability with your formulas.
Second thing I would do is build your formula table similar to what you have except that I would change your formula from being sheet and cell references to being you variable references:
A+B+C+D
A-B-C-D
A/B/C/D
A*B*C*D
Make sure the formulas are written with operators the same way you would if you were using a cell reference.
Then based on your lay out on sheet 3 I would use a VLOOKUP:
=VLOOKUP(E2,SHEET4!$A$2:$B$5,2,0)
Place that in F2 and copy down. That will tell you if you are pulling the right formula or not.
In G2 use the following:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(F2,"A",A2),"B",B2),"C",C2),"D",D2)
Check this to see that your substitution of your values for your variables is correct.
Then select cell H2 to make it the active cell. Then go Formula Ribbon and select Define Name from the Definied Names section.
Give a name for your formula such as ANSWER.
For your formula use
=evaluate(G2)
once you have added the defined formula to the list of formulas go to cell H2 and enter the following:
=ANSWER
now if you want to avoid all those helper columns, you can substitute one formula into the other.
I'm going around in circles with this and have tried as many different options as I can think of - VLOOKUP, INDEX/MATCH, IF etc... but I'm failing everytime.
I need to create a drop down list in sheet 3 (column A) that gets populated with values in column B of sheet 2, only where the value in column G of sheet 2 is "Yes". The values in sheet 2 look as follows:
This is what is shown at present:
I am using the following formula within Name Manager to get to this point:
=OFFSET(Units!$B$11,0,0,COUNTIF(Units!$B$11:$B$202,">"""),1)
and although this works, it's not quite as I need it to be. I've tried using Index/Match, small, VLOOKUP etc... but Excel reports that either I've too few arguments or can't reference a worksheet.
I've literally been though as many excel websites as I can find but no one seems to cover creating drop down lists where the drop down is dependent on a specific selection.
The values within sheet 2, column B are obtained from a hidden sheet and collected using the following query:
=IF(ISERROR(INDEX(All_Units!$D$2:$D$660542,MATCH(Units!A11,All_Units!$C$2:$C$660540,0))),"",INDEX(All_Units!$D$2:$D$660542,MATCH(Units!A11,All_Units!$C$2:$C$660540,0)))
I wondered whether I could take this query and use it to generate the drop down list, something along the lines of:
=INDEX(Units!$B$11:$B$202,MATCH(Units!$G$11:$G$202="Yes",Units!$G$11:$G$202,0)))
but this returns an error. The closest I got was using the OFFSET formula above but performing a COUNTIF, however; this unsurprisingly wouldn't tie Column B to the corresponding 'Yes' in column G.
Does anyone have any ideas as to how I can get this working?
You will need to create another sheet into which you will place an array formula. This formula will return all the desired output.
so create a sheet and name it something like DataVal
In A2 put the following array formula:
=IFERROR(INDEX(Units!$B$11:$B$202,MATCH(1,(Units!$G$11:$G$202="Yes")*(COUNTIF($A$1:A1,Units!$B$11:$B$202)=0),0)),"")
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter. If done correctly then Excel will put {} around the formula.
Then copy/drag down far enough to ensure capturing every possible return.
Then use another INDEX/MATCH to create the named range (OFFSET() is volatile and should be avoided when possible). The formula would be something like:
=DataVal!$A$2:INDEX(DataVal!$A:$A,MATCH("ZZZ",DataVal$A:$A))
This will dynamically set the named range to the extent of the dynamic list created by the array formula above.
I want to get sales by category (states).
In Sheet1, there're state's names in row A (A1 to A6) and cities in the column.
Each cities belongs to states,
e.g.
Sydney belongs to NSW, and Melbourne & Geelong belong to VIC.
Then Sheet2 contains sales data like shown below.
I want to calculate sales by state each month.
At the moment, each cells between row D and row I has a formula like below;
(e.g. F5)
=IF(AND(ISERR(SEARCH("Brisbane",B5)),ISERR(SEARCH("Gold Coast",B5)),ISERR(SEARCH("Cairns",B5))),"",C5)
But I'm sure there would be better and more simple nifty way to do this. As shops increase, this current formula gets more complicated. So it's needed to be optimized.
I would like to make these calculation simple using vlookup or something.. but no luck so far.
Any advice, detailed if possible, would be greatly appreciated! Thank you in advance :)
You can do this with an array formula. For example, in D3 use:
=IFERROR(IF(INDIRECT("Sheet1!A"&MAX(IF(ISERROR(SEARCH("*"&Sheet1!$B$1:$D$6&"*",$B3))+(Sheet1!$B$1:$D$6=""),0,ROW(Sheet1!$B$1:$D$6))))=D$1,$C3,""),"Not found")
(To enter an array formula, you need to press Ctrl+Shift+Enter)
The SEARCH looks at the store name in B3 and compares it to all names in Sheet1!B1:D6 with a * wildcard before and after. This won't be an error if it matches.
Adding the +(Sheet1!$B$1:$D$6="") gives an OR the cell is blank (otherwise ** would match).
If it isn't an error, we'll get the ROW of the corresponding match and we take the highest (MAX) row match.
We then use INDIRECT to get the cell value in column A of Sheet1 (the State code) and compare that to the state in the top row of our column
This is wrapped in an IFERROR to tell us if our store doesn't match any city
Array formulas are a great tool, but a little confusing! Rather than work on a single cell, array formulas work on each cell of an array. Typically this is for counts, sums, averages, etc. By including “logic maths”, you can do some really strange things in a single formula. A good resource is [link]http://www.cpearson.com/excel/arrayformulas.aspx Always remember to use Ctrl+Shift+Enter or really strange things will happen!