Extracting a number from a text string and returning a third value

steelervince

Board Regular
Joined
May 29, 2007
Messages
83
Hello All!

I have one Excel file

In Column B (275 rows) I have a number (all of these numbers are unique)
In Column C (275 rows) I have a string of text which contains several numbers within the string (all of the text strings are unique)
In Column D (275 rows) I have a different number from Column B (all of these numbers are unique)

what I need:

a formula in Column E that
Looks at the number in column B
Searches the text string in Column C for presence of the number in Column B
If the number from Column B exists in the text string in Column C then, return the number from Column D otherwise return the text "N/A"

Any help would be appreciated.

V
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hello,

Feel free to post a couple of examples to illustrate your expected result ...
 
Upvote 0
Without seeing any data, this is what I think you want (place formula in E2 and copy down):
Code:
=IF(ISNUMBER(SEARCH(B2,C2)),D2,"N/A")
 
Upvote 0
Column B
123456

Column C
186546 - some text; 134532 - some more text; 123456 - even more text

Column D
435671

Column E
I want excel to return 435671 here (in this example otherwise N/A goes here)
 
Last edited:
Upvote 0
Did you try my formula?
 
Upvote 0
Yes, I did Joe and it returned N/A in every cell in Column E
It works for me on the example you presented.

I am guessing that either:
1. You didn't update the formula correctly (to reflect the right row)
- or -
2. The are "extra" characters in column B that you aren't accounting for

Make sure that you do not have any extra/special/invisible characters in column B.

So, in your example, if "123456" is in cell B2, then see what this formula returns:
=LEN(B2)
If it returns any number greater than 6, you have some extra characters in there that you need to clean up (or adjust the formula accordingly).
 
Upvote 0
Thank you Joe!

This one is on me!!!! I forgot to mention that for each value in column B, I need the formula to search in over 1500 rows of data in Column C. So, I have B2 value as 123345 and then there are over 1500 rows of data in column C with varying text strings. If the value in B2 matches a value in say C150 then, I want the corresponding D150 cell number returned in E2.

I am sorry about that. Thank you for your time!

V
 
Upvote 0
OK, I see. Yes, very different.

Try this (in cell E2):
Code:
=VLOOKUP("*"&B2&"*",C:D,2,0)
 
Upvote 0
Joe

Excel returns a Value Not Available error and #N/A in column E. I understand the use of the * however, is Excel making the value in column B (for example) *123456*? I believe that what you are attempting to do is to have the value in column B have the wildcard characters before and after it, correct?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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