I have a lookup table like so:
a b c d
1 2 3 4
and a row filled with values a, b, c or d, for example:
d b b d c
I would like to get the minimum value after doing the lookup with the table in a single formula. Something like MIN(HLOOKUP(...)). In the example above, the result would be 2.
I know that I could create a new row with the HLOOKUP and later do a MIN on this row. But in my real case, I have several rows and several lookup tables and I would like to avoid having many intermediate rows.
Do you have any idea?
If your lookup array is named LetterValues and your data is in A1:E1 please try:
=HLOOKUP(CHAR(MIN(CODE(A1:E1))),LetterValues,2,0)
entered with Ctrl+Shift+Enter.
If you're data starts in cell A1, you can use the following array formula.
=MIN(IF(A1:E1="b",A2:E2,""))
It basically looks at the range A1:E1 and checks if it equals b. If it does, the formula stores the value from the row below, if not, it stores nothing.
Now that you have an array of all of the numbers associated with b, the MIN functions returns the smallest.
After typing in the formula, use Ctrl+Shift+Enter and curly brackets will appear around the formula.
Related
I have two sheets in Excel, Sheet1 and Sheet2.
They both contain 3 columns A, B and C.
My goal is to get values from C in Sheet2 to C in Sheet1, based on conditions comparing the values in both A and B at the same time.
A in Sheet2 contains numbers grouped together, for example 11,11,13,13,12,12. A in Sheeet1 contains some of those numbers, but not nessecarily in the same order or the same number of rows, for example 11,11,12,13,13.
B in Sheet2 also contains numbers like 2,1,1,2,1,2. B in Sheet1 again contains part of those numbers. For example, 1,2,1,1,2.
There are only unique combinations of pairs in A and B (in that specific order) for Sheet1 and Sheet2 respectively.
C in Sheet2 consists of numbers connected to the specific combination of numbers in A and B.
Now, I want to fill C in Sheet1 based on the values from C in Sheet2. For example for C1: Get the value (row x) in 'Sheet2'!Cx, so that 'Sheet1'!A1='Sheet2'!Ax, AND 'Sheet1'!B1='Sheet2'!Bx (which would be the 2nd row in this example).
I was thinking about something like
C1=INDEX('Sheet2'!C:C;...)
where
...=IF(AND(MATCH(A1;'Sheet2'!A:A;0);MATCH(B1;'Sheet2'!B:B;0));?;?)
?= I don't know what I would write here, but I would want the return value of IF be the row number where both conditions are true.
The problem is that MATCH only returns the first number in A and B respectively for which the condition is true, while I have several non-unique numbers in A. I would want to look through the whole 'Sheet2'!A:A and get all the matching values, and then look through the corresponding 'Sheet2'!B:B to check the second condition.
Or there might be a completely different take on this problem. Do someone have a suggestion on how to solve this?
Here is a way to look at multiple values in a MATCH() function, example:
Sheet1:
Sheet2:
Formula in C2 sheet1:
{=IFERROR(INDEX(Sheet2!$C$2:$C$6,MATCH(Sheet1!A2&Sheet1!B2,Sheet2!$A$2:$A$6&Sheet2!$B$2:$B$6,0)),"")}
Note: It's an array formula so enter through CtrlShiftEnter
Result:
C1 Formula =INDEX(Sheet2!C:C;MATCH(A1;Sheet2!A:A;0);MATCH(B1;Sheet2!B:B;0))
I need to check if a value from column E is between any pair of values in A:B and if so, return a letter from column C. Desired result is in F column.
I think an Array formula using Match() to get the row on which the hit is found that is then passed to INDEX() may solve this:
=INDEX(C:C,MATCH(1,(E3>=A:A)*(E3<=B:B),0))
That's an Array formula (CSE Formula) so you'll have to Ctrl+Shift+Enter it so it gets the squirrelly brackets.
If you have a value that falls into more than one range, this will return the first row too, which is a nice feature.
I'm using a vlookup to look for the all cells in the column D and see if they got a positive match in the C cells. If yes, I'm putting what is in the B cell next to the C cell.
In the example below, E2 will have what is inside of B2 after a lookup on D2 in the C column.
I've tried this formula but it is not the good one
=VLOOKUP(D2,C:C,0,FALSE)
I hope I don't need VBA
Best.
It is not completely clear exactly what you are looking for. I think you are trying to lookup data in column B based on a key in column C. If so what you want to use is
=INDEX(B:B,MATCH(D2,C:C,0))
As a breakdown, the MATCH will return a number representing which row within the range C:C matches the key D2. And, INDEX returns the element in B:B at row MATCH(D2,C:C,0).
I am trying to create a dashboard that will find the largest ten values based on data in column D and display the contents of column C while excluding from the selection any row that contains a specific value in column B.
I am currently using =INDEX($C$1:$C$100,MATCH(LARGE($D$1:$D$100,1),$D$1:$D$100,0)) to find the largest value in D and display C.
I can't figure out how to exclude from the LARGE call any rows that have SKIPME in column B.
You can use an IF statement to do that:
=INDEX($C$1:$C$100,MATCH(LARGE(IF($B$1:$B$100<>"SKIPME",$D$1:$D$100),1),$D$1:$D$100,0))
Except that it also converts the formula into an array equation, so that you now have to press Ctrl+Shift+Enter to make it work.
You can also use this equivalent function, also called with CSE but slightly shorter:
=INDEX($C$1:$C$100,MATCH(LARGE(($B$1:$B$100<>"SKIPME")*$D$1:$D$100,1),$D$1:$D$100,0))
Or if you're only looking for the biggest value, then MAX works just as well:
=INDEX($C$1:$C$100,MATCH(MAX(($B$1:$B$100<>"SKIPME")*$D$1:$D$100),$D$1:$D$100,0))
In order to avoid problems with duplicate values in column D you can use this setup:
In F2 down to F11 list the values 1 to 11
In G2 use this formula confirmed with CTRL+SHIFT+ENTER and copied down to get the associated values from column D
=IFERROR(LARGE(IF(B$2:B$100<>"SKIPME",IF(D$2:D$100<>"",D$2:D$100)),F2),"")
then to get the column C items for the top 10 values use this formula in H2 confirmed with CTRL+SHIFT+ENTER and copied down
=IF(G2="","",INDEX(C$2:C$100,SMALL(IF(B$2:B$100<>"SKIPME",IF(D$2:D$100=G2,ROW(D$2:D$100)-ROW(D$2)+1)),COUNTIF(G$2:G2,G2))))
If there are fewer than 10 qualifying values you get blanks - see example here
I have tried finding this solution on the web but have not had success for this specific problem. In Excel 2010 I have some data in column A where each value may partially contain data in column B.
EX:
Column A might contain "http://google.com/webmasters"
Column B might contain "google.com"
This should give me a match.
I want to print in Column C all values in column A that do not contain any values from column B.
EX:
Column A
http://dir.mydomain.tdl
http://myotherdomain.tdl
http://blog.otherdomain.tdl
http://www.lastdomain.tdl
Column B
mydomain.tdl
lastdomain.tdl
Column C (results required)
http://myotherdomain.tdl
http://blog.otherdomain.tdl
Any help would be greatly appreciated.
I think I have the solution using ARRAY formula. Assuming your input AND that columns A-C have titles, or simply, strings are listed starting cells A2 and B2, do the following:
C2: type the formula =IF(OR(NOT(ISERROR(SEARCH(INDIRECT("B2:B"&(COUNTA($B:$B))),$A2)))),"",$A2) but press CTRL+SHIFT+ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {} brackets around it (but do NOT type them manually!).
Autofill formula in C2 until the end of list in column A, e.g. if the last value is in A100, then autofill up to C100 (how long column B does not matter here).
You may then copy & paste obtained results as values and sort out empty strings.
Here you go! The key here - we check every string in column A for having at least one match among array of strings in column B, and return empty string in case at least one match found.
For your convenience sample file is shared: https://www.dropbox.com/s/janf0xxon4z2yh5/DomainsLookup.xlsx
Maybe not the must efficient but you could simply use two arrays - one for Column A and one for Column B. Iterate through ColumnA array to see if it exists in ColumnB array (use Array.IndexOf or .contains). If it does you could remove it from the ColumnA array and output the remaining values in Column C as the remainder.