Excel vlookup help - excel

Using vlookup, when a match occurs, I want to display the value of column C from sheet 2 from the same row where the match occurred. The formula I came up with takes the value from column C sheet 2 but it takes it from the row where the formula is pasted on sheet 3 instead of where the match occurred.
Here's my formula that doesn't work:
=IF(VLOOKUP(Sheet1!A:A,Sheet2!A:A,1,FALSE),Sheet2!C:C,"NODATA")
How can I take the value from the row where the match occurred?

To be clear, I am not entirely certain I understand what you are trying to achieve. Maybe the following helps...
Suppose I have 3 sheets in a workbook as follows:
Sheet1 Sheet2 Sheet3
A A B C A B
1 10 2 h Apple 10 Apple
2 20 g 4 Banana 25 n/a
3 30 l ! Pear 40 Grape
4 40 g * Grape 30 Pear
In column B of Sheet 3 I have the following formula:
=INDEX(Sheet2!$C$1:$C$4,MATCH(VLOOKUP(A1,Sheet1!$A$1:$A$4,1,FALSE),Sheet1!$A$1:$A$4,1))
To explain:
The VLOOKUP looks up the value from Sheet 3, Col A in Sheet1
The MATCH returns the row in Sheet1 of the VLOOKUP result
The INDEX then uses the row number to pick the right value from the value in Sheet2
Again, not sure if this is what you wanted exactly. It may help you get you started...

You need to manually get the index you're looking for, then get the value at that index:
=INDEX(Sheet2!C:C, MATCH(Sheet1!A:A,Sheet2!A:A,FALSE))

Related

How to find and replace from a List in Excel

Not using VBA but just simple excel, can anyone help me find a solution to this problem? Would greatly appreciate it!
I have a list of Names in Sheet 1 like below
-
A
1
sp_abc_Rick
2
sp_abc_Jabba_the
3
sp_abc_Dany
4
sp_random_Rick
5
sp_random_Jabba_the
6
sp_random_Dany
7
sp_constant
8
sp_ripley_art_Dany
9
sp_ripley_art_Jabba_the
10
sp_wakeup
I have a list of Mapping Table in Sheet 2 like below
-
A
B
1
Rick
Morty
2
Jabba_the
Hutt
3
Dany
Dragon
I wish to have a result in Sheet 1, in column B, like below
-
A
B
1
sp_abc_Rick
sp_abc_Morty
2
sp_abc_Jabba_the
sp_abc_Hutt
3
sp_abc_Dany
sp_abc_Dragon
4
sp_random_Rick
sp_random_Morty
5
sp_random_Jabba_the
sp_random_Hutt
6
sp_random_Dany
sp_random_Dragon
7
sp_constant
sp_constant
8
sp_ripley_art_Dany
sp_ripley_art_Dragon
9
sp_ripley_art_Jabba_the
sp_ripley_art_Hutt
10
sp_wakeup
sp_wakeup
To give you a context of the number of rows. Sheet 1 will be bigger with more than 1000 rows. Sheet 2 (Mapping Table) is constant set of rows. Currently it is about 100 rows.
You can use a formula like shown below using LOOKUP(), SEARCH() with SUBSTITUTE()
• Formula used in cell B1
=IFERROR(SUBSTITUTE(A1,LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$D$1:$D$3),
LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$E$1:$E$3)),A1)
There you go. There may have other better solution. This is what I got.
All in column B.
=IFERROR(CONCAT(MID(A1,1,MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)-1),INDIRECT(CONCAT("sheet2!b", MATCH(MID(A1, MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE), LEN(A1)), Sheet2!$A$1:Sheet2!$A$300, 0)))),A1)
Break down is as follow;
Let's start put things from Column C onward.
Column C, to find the index of the first capital letter from the text.
ref: http://dailydoseofexcel.com/archives/2007/02/21/find-position-of-first-capital-letter-in-a-string/
=MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)
Column D, cut the name part by using upper case letter index from column C, sp_abc_Jabba_the -> Jabba_the
=MID(A1, C1, LEN(A1))
Column E, search row number from Sheet2 by matching Column D's name with Sheet 2's Column A, this will get matching row number from Sheet2.
=MATCH(D1, Sheet2!$A$1:Sheet2!$A$300, 0)
Column F, get Sheet2's Column B value by the row number from Column E.
=INDIRECT(CONCAT("sheet2!b", E1))
Column G,
Cut "sp_abc_" from "sp_abc_Rick"
Concat "sp_abc_" with Column F's "Morty".
If there is any error, use Column A value as default.
. <- this dot is intentional. please ignore.
=IFERROR(CONCAT(MID(A1,1,C1-1),F1),A1)
Try:
Formula in B1:
=BYROW(A1:A10,LAMBDA(a,LET(b,TEXTBEFORE(a&"|","_"&A12:A14&"|",-1),IFERROR(CONCAT(IF(b&"_"&A12:A14=a,b&"_"&B12:B14,"")),a))))
The concatenation with a "|" would assert we only replace values when at the exact end of the input. Just in case there would be a stray (for example) 'Rick' somewhere before the end.

Average Vlookup values if it Cell X matches Cell Y in another sheet

So here's my problem:
I've got 2 sheets. (A and B).
2 Cells 2 Match (SheetA!A and SheetB!A)
6 Columns to average (B-C-D-E-F-G)
SheetA!A1 and SheetB!A1 If those two match, the average needs to be for cells B1-C1-D1-E1-F1-G1).
I've got a few thousands rows in each sheet. SheetA is the "Data Sheet" where all the data is. And SheetB is like my workbook, where all the stats will be.
I tried this function:
=AverageIf(SheetA!$A:$A;A2;SheetA!B:G)
I also tried
=average(index(SheetA!$B:$G;MATCH($A2;SheetA!$B:$G;0)))
Which doesn't seem to work either. But I know I probably made an error with this formula.
The function only gives me the value in cell B, it doesn't calculate the average for the 6 cells on the same row. Text1 and Text5 are the texts to Match from SheetB in SheetB
##SheetA##
A B C D E F G
Text1 1 2 3 1 2 3
Text2 2 3 1 1 1 1
Text3 1 1 2 1 2 2
Text4 3 5 2 4 5 1
Text5 4 2 2 2 2 2
##SheetB##
What I would like on SheetB:
A B
Text1 2
Text5 2.33
The formula I showed Previously gets me the following, it doesn't calculate the average, only gets me the first value:
A B
Text1 1
Text5 4
It matches the right row with Text1 from SheetA and SheetB.
Ok, this will work if you have the data as I show. If not, you need to adapt the MATCH part to make sure the formula will work.
Data in SheetA is like this, starting at row 1 (this is important):
My formula is in SheetB in column B, and is like this:
=AVERAGE(INDIRECT("SheetA!B"&MATCH(A1;SheetA!A:A;0)&":G"&MATCH(A1;SheetA!A:A;0)))
And I get this:
How this works:
MATCH will get the row number of the range you want to average (if found, ofc). Because my data starts at row 1, the number returned by MATCH is good. If your data does not start at row 1, you need to adjust it (+1,+2, whatever you need).
INDIRECT will return the range in same row, but between columns B and G from SheetA
Finally, AVERAGE will make the average.
There is no error handling if something is not found, but if you need it, just add something like IFERROR.
Also, MATCH will only work if the match is 100% exact. In your example in SheetA you have Text1 but in SheetB you typed Text 1, which are not equal. Make sure you type them right.
Hope you can adap this to your needs.

Extract Value from Column A and then get the count for certain values from Column B for the value in Column A

The table structure that I have right now is as below:
Column A Column B
Apple 1
Apple 2
Apple 1
Orange 1
Orange 2
I am trying to write a formula where, for all the cells with the value of Apple in column A, I get the total count for values in column B equal to 1.
Please help.
As far as I can tell, you are just after the formula
=COUNTIFS(A:A,"Apple",B:B,1)

A function that will lookup a reference

Before I get started thanks for taking your time and helping.
This is what my worksheet looks like:
Row # B C D E F
2 1 Product 1 B2 B3 B4
3 2
4 6
5 1 Product 2 B5 B6
6 5
7 4 Product 3 B7
I was trying to follow this formula: (The best answer one or green check mark) return values from multiple matching rows
I got all the way to the =IFERROR(INDIRECT(lookups!H5),"") but can not get this to work.
What I am tying to do is order the numbers in Column B to go to the right of the product. Which I was able to get the column it is in (B) and the row number it is in (B2). I would like to change the value (B2) to the number that is there.
I would like it to look like this:
Row # C D E F
2 Product 1 1 2 6
3
4
5 Product 2 1 5
6
7 Product 3 4
If someone could help explain this to me or find a better way that would be great.
Not sure what is to happen to columnB but if you replace B with "="B throughout columns D:F then select each of these in turn and apply Text to Columns with Tab as the delimiter the 'cell references' convert to formulae referring to the values in B. If you want to delete columnB copy D:F and Paste Special, Values over the top.

Find value in 2D array and return value in adjacent cell

**Sheet 1**
ColumnA B C D E F G H
------------------------------------------------------------
EURUSD 1.2765 1 ACCOUNT624 2 account125 1 account834
EURCAD 1.01 2 Account49 3 account45 2 account67
EURGBP 0.78 2 Account777 1 account45 2 account678
**Sheet 2**
ColumnA B C D
---------------------------------------
EURUSD 1.2765 Account 624 ?
EURUSD 1.2765 Account 125
EURUSD 1.2765 Account 834
EURCAD 1.01 Account49
EURCAD 1.01 Account45
In Sheet 1 above each row shows a currency trade and what quantity goes to each account.In Sheet 2 each row shows 1 account only. I would like to populate columnd D in sheet 2 with the quantites from sheet 1.
Breaking it up into steps, i would like to:
Find the price in Sheet2!B1 in sheet1
On the same row in sheet1, find the cell containing the same account as Sheet2!C1
Return value in cell to the left of cell with matching account
I have used index/match before but I can't get it to work for 2 dimensional arrays. Can anyone help with a formula? Thanks in advance!
It's not pretty, but using what you requested - to find the match based upon price in column B (I would say your safer bet would be to use the Currency conversion "EURUSD", for example, since what if 2 currencies have the same ocnversion rate??), paste this formula in cell D1 on your second sheet:
=OFFSET(Sheet1!$B$1,MATCH(B1,Sheet1!$B$1:$B$3,0)-1,MATCH(C1,OFFSET(Sheet1!$B$1,MATCH(B1,Sheet1!$B$1:$B$3,0)-1,0,1,10),0))
You can then drag it down / change ranges as needed.
(PS - I'm also assuming you made a mistake on sheet2 and that the account numbers will be typed the exact same in both sheets)

Resources