If value (A2) is in Column J or J, then return Column L

atoice

New Member
Joined
Aug 14, 2019
Messages
9
Office Version
  1. 2013
Platform
  1. Windows
Hi Community,

I am trying to find if a value is found in one or two columns to return a value from another column. I have tried, Vlookup with IF / Or, Match with IF/OR, Index / Match, and plain IF/OR. I have not had any luck. I am hoping you can help. A snapshot is attached - very simple example that would be used for huge database.

I want C2 to return the value in column L if A2 is found in either column J or K). In this case, C2 would be 1. The other example with the "or" as in C22 would be 2 (as the total is found in column K). Is that possible? Your help is greatly appreciated. Thank you in advance.
1645815621537.png
 

Attachments

  • 1645815304426.png
    1645815304426.png
    66.1 KB · Views: 6

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
Sorry - thanks for your reply. it's excel 2013. I'll drop it in.
 
Upvote 0
Thanks for that.
How about
Excel Formula:
=INDEX($L$2:$L$100,IFNA(MATCH(A2,$J$2:$J$100,0),MATCH(A2,$K$2:$K$100,0)))
 
Upvote 0
Hi,

Another way:

Book3.xlsx
ABCDEFGHIJKL
1
210011100110011
310022100211022
410033100311033
510044100411044
610055100510055
710066100611066
810077100710077
910088100811088
1010099100910099
111010101010101010
121011111011101111
131012121012111212
141013131013111313
151014141014111414
161015151015101515
171016161016101616
181017171017101717
191018181018111818
201019191019111919
211020201020102020
2211022
Sheet1020
Cell Formulas
RangeFormula
C2:C22C2=LOOKUP(2,1/FIND(" "&A2&" "," "&J$2:J$21&" "&K$2:K$21&" "),L$2:L$21)
 
Upvote 0
Hi Jtakw! JACKPOT! Thank you so much for your quick reply. I did try using Find as well, and no luck. I didn't know Lookup could be used alone. V/H/or X.

Would this apply to if the columns were on another tab for Lookup/Find, correct?

Have a great weekend.
MT
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0
At OP's request, here's an explanation of my formula in Post # 5.

The LOOKUP function is looking for the value of 2 within the "lookup vector", which, in this case is:

1/FIND(" "&A2&" "," "&J$2:J$21&" "&K$2:K$21&" ")

We want to find the value of A2 (e.g. 1001) in either Column J or Column K,

So I used the FIND function (case sensitive, but since we're dealing with numbers, makes no difference) but added a Space before and after the value of A2 (e.g. " "&A2&" "), so A2 becomes " 1001 "

I also concatenated Column J and Column K, Also adding a Space before, in between, and after the Column J & K values per row (e.g. " "&J$2:J$21&" "&K$2:K$21&" "), so J2:K2 becomes " 1001 1001 ", J3:K3 becomes " 1002 1102 ", and so on for Each row.

The reasoning behind adding the Spaces is to avoid the possibility of erroneous results from values like:
A2=1011, J2=1010, K2=1102
Without the addition of the spaces, J2&K2 becomes "10101102" which Does contain "1011", and the FIND function will interpret that as a Match
With the addition of spaces, J2&K2 becomes " 1010 1102 " which does Not contain " 1011 ", so it's Not a Match.

So now, 1 is divided by the results of the FIND function, thereby, making the FIND results Never larger than 1

LOOKUP is looking for 2 within a vector that Only contains numbers that are 1 or smaller and #VALUE! errors,
LOOKUP will ignore the errors, but can't find the 2, so it resolves to produce the Last instance of a number Smaller than 2
and produces the Position of this value within the "result vector" in the formula L$2:L$21

My formula in Post # 5

=LOOKUP(2,1/FIND(" "&A2&" "," "&J$2:J$21&" "&K$2:K$21&" "),L$2:L$21)

Does Not have to be written with the "2,1/" part, bold in red above, it could also be written as:

=LOOKUP(9.99999999999999E+307,FIND(" "&A2&" "," "&J$2:J$21&" "&K$2:K$21&" "),L$2:L$21)

where we use the commonly referred to as BIG NUM (the largest number Excel will recognize), the principle is the same.
Some excel users my use something like 9^9 or 2^15, rather than the BIG NUM, there are instances where these values will suffice for the purpose of the calculation, but may Not work in All instances.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,734
Members
449,094
Latest member
dsharae57

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