Outputting numbers extracted from a string

thinksmart12

New Member
Joined
Jan 14, 2016
Messages
2
Hey everyone,
I am trying to create a function that will extract a number in the given string and print that number in the cell. I had this issue in the past and found the solution on these forums using either LOOKUP or VLOOKUP, but stupid me cannot find that post again.

I have data that looks like this:

AB
Lab 5 because seeing the titration first hand helped me to understand the equivalence point.

<tbody>
</tbody>
5
Experiment 12 because it gave me a huge understanding of how to use the gas laws and apply it to real situations.

<tbody>
</tbody>
12
Lab 10

<tbody>
</tbody>
10
The last lab report, lab 12 required me to use a lot of things that we've learned throughout the semester and really made some things make more sense.

<tbody>
</tbody>
12
Lab 10: Qualitative Determination of Selected Metal Cations. This lab supported the course content because it gave me a "real world" relation to what was being studied.

<tbody>
</tbody>
10
The calorimetry lab really helped my understanding of the use of the different equations and the types of problems I would encounter on the test.

<tbody>
</tbody>
4

<tbody>
</tbody>

What I want to first accomplish, is to put some formula and drag it down in column B, so that B gets populated with the numbers from column A. I have hundreds of rows where there is some number given in column A. I would like to drag down over the hundreds of rows and have it output the corresponding number from column A into column B.

If you look at the last row in italics, there is no number in column A. For these rows, I would like to have a formula that searches for certain keywords (in this case, the word "calorimetry") and output a number based on that. If the keyword is not present, then skip it. I can then modify this formula to search for different words and output different numbers based on that.

If anyone can help with this, that would be great! Like I said, I think the solution to this was posted in this forum before, but after extensive searching I cannot find it.

Thank you!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
This isn't particularly elegant...but...
With your sample data in A1:A5
A
1
Lab 5 because seeing the titration first hand helped me to understand the equivalence point.​
2
Experiment 12 because it gave me a huge understanding of how to use the gas laws and apply it to real situations.​
3
Lab 10: Qualitative Determination of Selected Metal Cations. This lab supported the course content because it gave me a "real world" relation to what was being studied.​
4
The last lab report, lab 12 required me to use a lot of things that we've learned throughout the semester and really made some things make more sense.​
5
Lab 10: Qualitative Determination of Selected Metal Cations. This lab supported the course content because it gave me a "real world" relation to what was being studied.​
6
The calorimetry lab really helped my understanding of the use of the different equations and the types of problems I would encounter on the test.​

and this lookup table:
F
G
1
Text​
Value​
2
Calorimetry​
4​
3
Kniffle Pin​
1​
4
Snucky​
2​

This formula, copied down, returns the embedded number from the text. If no number is found, the formula tries to find the lookup text candidates in the text and returns an assigned value
Code:
B1: =IF(MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")) < LEN(A1)
,LOOKUP(99^99,--("0"&MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW($1:$10000))))
,IFERROR(INDEX($G$2:$G$4,MATCH(1,INDEX(COUNTIF(A1,"*"&$F$2:$F$4&"*"),0),0)),0))

Is that something you can work with?
 
Last edited:
Upvote 0
Yes, this is perfect - you are a life saver!


This isn't particularly elegant...but...
With your sample data in A1:A5
A
1
Lab 5 because seeing the titration first hand helped me to understand the equivalence point.​
2
Experiment 12 because it gave me a huge understanding of how to use the gas laws and apply it to real situations.​
3
Lab 10: Qualitative Determination of Selected Metal Cations. This lab supported the course content because it gave me a "real world" relation to what was being studied.​
4
The last lab report, lab 12 required me to use a lot of things that we've learned throughout the semester and really made some things make more sense.​
5
Lab 10: Qualitative Determination of Selected Metal Cations. This lab supported the course content because it gave me a "real world" relation to what was being studied.​
6
The calorimetry lab really helped my understanding of the use of the different equations and the types of problems I would encounter on the test.​

<tbody>
</tbody>

and this lookup table:
F
G
1
Text​
Value​
2
Calorimetry​
4​
3
Kniffle Pin​
1​
4
Snucky​
2​

<tbody>
</tbody>

This formula, copied down, returns the embedded number from the text. If no number is found, the formula tries to find the lookup text candidates in the text and returns an assigned value
Code:
B1: =IF(MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")) < LEN(A1)
,LOOKUP(99^99,--("0"&MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),ROW($1:$10000))))
,IFERROR(INDEX($G$2:$G$4,MATCH(1,INDEX(COUNTIF(A1,"*"&$F$2:$F$4&"*"),0),0)),0))

Is that something you can work with?
 
Upvote 0
Another option in using Ron's Lookup Table F2:G4 in post# 2 :

=IFERROR(-LOOKUP(,-(MID(A1,MIN(FIND({0;1;2;3;4;5;6;7;8;9},A1&1/19)),ROW($1:$20))&"**0")),IFERROR(LOOKUP(1,-SEARCH(F$2:F$4,A1),G$2:G$4),""))

Regards
 
Upvote 0

Forum statistics

Threads
1,217,361
Messages
6,136,105
Members
449,993
Latest member
Sphere2215

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