I am currently in the process of trying to create a vlookup function that will check cell A2 and check it on sheet1. If it brings back an error, it should go to B2 and then check on sheet1 and bring back the results.
This is what i currently have:
=IF(ISNA(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE)),"0",VLOOKUP(B2,'Sheet1'!$A$2:$A$1932,1,FALSE))
But it doesn't seem to be bringing back all the results, it is bringing back some results from each list A2 and B2.
What am i doing wrong?
Thanks in advance.
This should work:
=IFERROR(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE),VLOOKUP(B2,'Sheet1'!$A$2:$A$1932,1,FALSE))
It will use A2 to and try and find it in sheet1 and if it returns an error, it will go B2 and find the item on sheet1.
Try using:
=IF(ISNA(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE)),"0",VLOOKUP(A2,'Sheet1'!$A$2:$B$1932,2,FALSE))
Or you can use an IFERROR to make things shorter:
=IFERROR(VLOOKUP(A2,'Sheet1'!$A$2:$B$1932,2,FALSE),"0")
(You can omit the quotes around 0 if you mean a numerical 0 as opposed to a text 0)
This formula will get the value from column B in Sheet1 using the lookup value A2 from Sheet2 and looking it up in column A in Sheet1.
VLOOKUP checks the value of A2 in column Sheet1!A:A and returns the value from column Sheet1!B:B with the formula:
=VLOOKUP(A2,'Sheet1'!$A$2:$B$1932,2,FALSE)
^ ^
1 2
B is the result column
2 is in the index relative to A. A is column 1, B is column 2.
EDIT:
If you want to get the value from column A only, checking the value of A2 first and B2 on failure of the first, then you can use:
=IFERROR(VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE),VLOOKUP(A2,'Sheet1'!$A$2:$A$1932,1,FALSE))
Related
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
What's a good way to search a column of text (e.g. A1:A10) by adjecent cell (e.g. B1) and return a binary value (e.g. 0 or 1) in the next column (e.g. C1:C10)?
my 'un-elegant' approach so far: use VLOOKUP, then filter and delete all fields that return an error.
A simple MATCH will do for you
=IF(ISNUMBER(MATCH("*"&B1&"*",A1:A10,0)),1,0)
if I understand your question correctly you are wanting column C to show 1 or 0 depending on whether text in column B appears in text in column A, if so:
formula in C2 to extend down =if(find(B2, A2) > 0, 1, 0)
FIND will return the location of the first occurrence of the first argument within the second
EDIT
Ok, if you want to check all of column A use this:
=OR(NOT(ISERROR(FIND(B1, A1:A8))))
Again its array formula so complete with CTRL+SHIFT+ENTER
So its doing a FIND for B1 against all of column A, any row that doesn't contain B1 is going to return an error. So now you have an array whose values are either ERROR or a number indicating B1 is found, you can then use the ISERROR function on each element of the array and then NOT each element, you will then have a TRUE for each row B1 appears in, then collapse it all to a single value using OR :) you can extend this formula in B1 down for the other rows but make sure to lock A1:A8 as in $A$1:$A$8
I have a lookup that works for a single column:
=IFERROR(INDEX($C$2:$C$145,MATCH(A2,$D$2:$D$145,0)),"")
If A2 matches the range of values in D2 to D145, then output the corresponding C2 to C145 value in cell B2
This populates column B2 successfully.
How could I put that into a loop, so that $D2:$D145 iterates between column D and column GS
Really appreciate any hints from anyone at this point.
if its possible add column after gs and fill it with hlookup fomulas and then match by this column
hlookup formula for GT2:
=iferror(hlookup(a$2,indirect("D"&row(gt2)&":GS"&row(gt2)),1,0),"")
and copypaste it down until GT145; and your formula changes to:
=IFERROR(INDEX($C$2:$C$145,MATCH(A2,$GT$2:$GT$145,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)
How to solve this case:
Suppose there are two columns having same text assigned with values then i need to subtract those values to get the result in a new cell
For eg: if james in cell a1 has been assigned value as 20 in cell b1 and also james in cell c2 has been assigned value as 40 in cell d2, then i need to get the result as (40-20=20) in a different cell such that while giving the formula the James in cell a1 and c2 has to be same and only there corresponding values get subtracted and not with any other cell.
Please help me on this.
I find it a little strange that you would be starting with C and subtracting A, but okay. If what you are doing is looking for a name in C and taking the number in the right column then subtracting that from the value to the right of the same name in A, then VLookup has you covered:
=VLOOKUP("james",C:D,2)-VLOOKUP("james",A:B,2)
You can also use a formula based on INDEX and MATCH, which doesn't require cells to be sorted (as VLOOKUP does):
=INDEX(B:B; MATCH("James";A:A;0)) - INDEX(D:D; MATCH("James";C:C;0))
If either A:A or C:C doesn't have a "James", then the formula will return #NA. You can avoid this by adding a conditional to check whether the match is valid.
For example, if column C might not contact "James", replace
INDEX(D:D; MATCH("James";C:C;0))
with:
IF(ISNA(MATCH("James";C:C;0)); 0; INDEX(D:D; MATCH("James";C:C;0)))
which will then return 0 if there is no James in column C, otherwise the corresponding value in column D will be returned.