Righto,
I need a formula to put in A2. I need to compare B2:B10 to G2:G10, and if theres a match, return the value in F.
For example, if the formula was in A1, it'd find the matching number (4321) in G7, and then return the value in F7 back to A1
I've tried using Index with Match, but didn't work :( Any suggestions?
An index and match should solve this. Index the range you want to return, and then an exact match looking up your value in column B to the range in column G should get you the value you are looking for.
Example if typed into cell A2 in your picture:
=INDEX($F$2:$F$10, MATCH($B2, $G$2:$G$10,0) )
If there is only one match for each value in column G, I would use the following Index/Match formula in field A2:
=index(F:F, match(B2,G:G,0))
Note: I will only return the first value if the value appears multiple times in the column.
In H2 enter:
=IF(B2=G2,F2,"")
and copy down. In A2 enter:
=TEXTJOIN(",",TRUE,H2:H10)
This will gather all matches.
Related
I have the following structured table in excel where 1000s of rows included.
I want to return the Last Cell Value of Column B for Each value in Column A.
For example:
For Cell A1 -> I want to return the Cell B5.
For Cell A6 -> I want to return the Cell B9.
I have tried with VLOOKUP, HLOOKUP, INDEX likewise so many formulas where I ended with more conflict situations. Can anyone please write down a Formula to give my requirement a life?
Array formula (Press Control + Shift + Enter while entering the formula) in cell C1 and copy it down.
=IF(A1="","",IFERROR(INDEX($A2:$B$20,MATCH(FALSE,ISBLANK($A2:$A$20),0)-1,2),LOOKUP(2,1/(B2:$B$20),B2:$B$20)))
if you don't mind using column C as a helper column you could use something like that:
If you won't use Array formula you can Use this solution:
like this image:
use column C as helper with this formula in first cell =OFFSET(A1;SUMPRODUCT(MAX(($A$1:$A1<>"")*(ROW($A$1:$A1))))-ROW(A1);0)
and use this formula in column D's first cell =IF(A1="";"";INDEX($B$1:$B$13;SUMPRODUCT(MAX((ROW($A$1:$A$13))*($C$1:$C$13=A1)))))
and copy fill-down to all cells.
Try this shorter, without helper column and non-array formula solution
In C1, formula copied down :
=IF(A1="","",INDEX(B1:B$9,MATCH(1,FREQUENCY(1,0+(A2:A$9<>"")),0)))
From my research, when a bunch of cells are merged, you can only reference the first row and first column of the merged cells. EG. if A1:A3 are merged, then I can only access the data using A1 only, and A2 and A3 returns 0.
Now let's say I have a column B that has a formula that calculates based on values in column A. If I drag this formula down, then B2 and B3 will end up using value of 0, when they should be using value in A1.
Effectively, what i want to do is "if the cell in column A (of this row) is blank, then use the last non-blank value going upwards".
I know this will need to combine a couple of formulas, but I can't figure out how to create this. For a start, I can use the Offset function to "go up", but the difficult part here is how to find the previous non-blank cell?
I also tried combing OFFSET with COUNTA (see https://www.exceltip.com/other-qa-formulas/get-the-value-of-the-last-non-blank-cell-in-a-column-in-microsoft-excel.html), but this doesn't work if this occurs multiple times.
Easiest way is to use a helper column:
In B2 write
=IF(NOT(ISBLANK(A2)),0,B1+1)
and in C2 write
=OFFSET(A2,-B2,0)
Edit: actually... the solution without helper column is even easier! Write in B2:
=IF(ISBLANK(A2),B1,A2)
To avoid the helper column, you can use the INDEX + AGGREGATE functions:
=INDEX($A$1:A1,AGGREGATE(14,6,($A$1:A1<>"")*ROW($A$1:A1),1))
I have been trying this for days, and can't get it correct.
I want to see if any value in column A matches any value in column C, and if so, return the value from column B into column D, BESIDE the match in column C.
I have tried all the suggestions for If, IFERROR, MATCH, VLOOKUP, etc, but can't get it to work. Any help would be most welcome!!
Here is a picture of my spreadsheet
Use a helper column:
In column D, use COUNTIF on each row to check the number of times that a cell in column A appears. =COUNTIF(C:C,A1).
In column E, use the formula =IF(D1>0, B1,"") and copy down
(you could of course combine these if you don't want to use the extra column)
Assuming you're starting in Row 1, in column D use:
=IF(COUNTIF($A:$A,$C1)>0,B1,"NO MATCH")
Drag that down as far as you need. This formula is saying: if the value in C1 matches anything in column A, then return the value from B1.
If this isn't what you mean, then please be clearer. Your data example is unreadable. Post a screenshot, or at least type it so it is in columns and rows. It's also unclear what you mean by "BESIDE the match in column C" What value is matching which value? That is, if A1 matches any value in C, do you want the value of B1 to show up in D1? Or do you want the value of B5 to show up in D5, if A1 matched C5?
In coumn D use formula
=IFERROR(VLOOKUP(C:C,A:B,2,0),"")
Note: this formula uses Implicit Intersection see here for some info
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 have checked alot of INDEX and MATCH formula but can't nail this if someone can point me in the right direction to compare one cell in the C column against all cells in Column A and Column B and if it is in neither enter C2 in D2 so I have a list of numbers not in either column A or B.
So the idea is I check every C column cell against the other two columns and show the C cells that are in netiher.
Hopefully this pseudo code helps explain:
IF (cell C2 is not anywhere in column A OR not anywhere in column B) then return cell C2 in Cell D2
This one works for one column check:
=INDEX(C$2:C$23,MATCH(C2,A$2:A$23,0))
but I need two column check but the below does not work for me as it just says #N/A even for the row that was working for the single column check formula above. I I wondering if I can put an OR in the middle of the two matches or maybe you can suggest it a different way.
=INDEX(C$2:C$23,MATCH(C2,A$2:A$23,0),MATCH(C2,B$2:B23,0))
Thanks in advance.
Try using COUNTIF like this
=IF(COUNTIF(A$2:B$23,C2)=0,C2,"")
or if columns are not adjacent
=IF(COUNTIF(A$2:A$23,C2)+COUNTIF(B$2:B$23,C2)=0,C2,"")
Those will return C2 value if it's not in either column....otherwise a blank
....if you really want to use MATCH try this version....
=IF(COUNT(MATCH(C2,A$2:A$23,0),MATCH(C2,B$2:B$23,0))=0,C2,"")
And one more version using VLOOKUP:
=IF(AND(ISERROR(VLOOKUP($C$2,$A:$A,1,0)),ISERROR(VLOOKUP($C$2,$B:$B,1,0))),"",$C$2)