Excel if, look, find, take, and put

Bookmaster

Board Regular
Joined
Mar 22, 2014
Messages
85
Office Version
  1. 2021
Platform
  1. Windows
Hello,
I need help with the excel function or it could be a VBA.

I have an excel worksheet with tho sheets.



I need a function that will:

On Sheet 1, take the value found in field A2, then look for that value on Sheet 2 in Column B. If found, it should take the value from column A from the same row on Sheet 2 and write it on Sheet 1 in column N line 2.

Then he should take the value in field A3 on Sheet 1 and look for the same value on Sheet 2 in column B. When it is found, it should take the value from column A from the same line on Sheet 2 and write it on Sheet 1, in column N, in row 3

So it takes value from A on Sheet 1, look for that value in Column B on Sheet 2. When it is founds take the value from column A from the same line where the value is found and put it in column N in the line where starting value is taken, on Sheet 1.

Note that values in column B on Sheet 2 are complex, I mean it contains many words and characters. The function should find the same value anywhere in column B.



Example:



On Sheet 1 in field A2 I have the number 10710. The function should take that number, and look for it on Sheet 2 in column B. Let's say we find it in field B67. Now take the number from field A67 on sheet 2 and put it in field N2 on Sheet 1.

Then on Sheet 1 in field A3 I have the value HK1119630. The function should take that value, and look for it on Sheet 2 in column B. Let's say it was found in field B375. Now the function should take the value from field A375 from Sheet 2 and write it into field N3 on Sheet 1



The function should go all the way until it has passed all the values found on Sheet 1 in column A
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Something like this: For office 365, if you have XLOOKUP. IM not sure if you have it in 2021.
Other wise use INDEX/MATCH.


WorkBook1.xlsx
ABCDEFGH
3With Index/Match
4sheet1Sheet2
5Col ACol NCol AColB
6107109113711058464749Row1
7HK11963050754010313434040Row2
84822279357Row3
9with XLOOKUP4237938271Row66
1010710911379113710710Row67
11HK1196305075406326615297Row68
122551391265Row373
133742179561Row374
14507540HK119630Row375
153438861975Row376
165948816381Row377
17
Sheet1
Cell Formulas
RangeFormula
B6:B7B6=INDEX($E$6:$E$16,MATCH(A6,$F$6:$F$16,0))
B10:B11B10=XLOOKUP(A10,$F$6:$F$16,$E$6:$E$16)
 
Upvote 0
Hello awoohaw,

Thanks for the fast reply. I do have the XLOOKUP function and I am stuck in it just because I'm always getting results as #N/A.
My function is: =XLOOKUP(A2;'Sheet2'!B:B;'Sheet2'!A:A).
The problem could be that in range B:B I don't have just a value from A2 but also other values. In that case, XLOOKUP would have to search within every cell in the B column.

Do you have any suggestions, please?
 
Upvote 0
Yep, when doing the XMATCH with the 'exact match' attribute, which is the default you get N/A when there is not an exact match. Does the cell Start with the same value? you could use one of the other atributes.. but that kind of matching also require some consistency. there are more expert ways of matching.. but I am not well versed in that.

Is there a way to parse the data in A2 to separate the lookup value out? Maybe use a helper column?
 
Upvote 0
What about some sample data and expected results with XL2BB that exhibits the sort of variety that you have? Then explain again in relation to that visual sample data.
 
Upvote 0
Great!
Thanks for the tip.
Exact formula is = XLOOKUP("*"&A2&"*";'Sheet2'!B:B;'Sheet2'!A:A;;2)

With "*"& I covered all before and with &"*" I covered all after... basically covered found somewhere in line what II was looking for
Thanks for the guidance!
 
Upvote 0
Solution
Glad you found a solution. (y)

We can close this thread now.
We don't generally close threads in this forum as it is always possible that a better solution may come along later. However, if a post answers your question it can be marked as the solution, so you could consider that for post #6 since you did actually post the solution there. :)
 
Upvote 1

Forum statistics

Threads
1,215,013
Messages
6,122,690
Members
449,092
Latest member
snoom82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top