Extracting Numbers from Text String

2BLUE4U

New Member
Joined
Dec 6, 2023
Messages
11
Office Version
  1. 2019
Platform
  1. MacOS
I'm trying to extract grade scores from text strings like this: B (85.2%)

I need a formula that will automatically populate the 2nd column like this...

B (85.2%)85.2

I've tried so many different lookup formulas (including the one below) and none of them will extract the numbers correctly. Please help!

=LOOKUP(9.9E+307,--LEFT(MID(A2,MIN(FIND({1,2,3,4,5,6,7,8,9,0}, $A2&"1023456789")),999),ROW(INDIRECT("1:999"))))
 

Attachments

  • Screenshot 2023-12-06 at 3.50.51 PM.png
    Screenshot 2023-12-06 at 3.50.51 PM.png
    38.2 KB · Views: 26

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Book1
AB
1Grade SummaryGrade Raw Score
2A (100.0%)100.0
3B (85.2%)85.2
4B (80.8%)80.8
5C (71.7%)71.7
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=MID(A2, SEARCH("(", A2)+1, SEARCH("%", A2) - SEARCH("(", A2) -1)
 
Upvote 0
How about this:

Book1
AB
1Grade SummaryGrade Score Raw
2A (100.0%)100
3B (85.2%)85.2
4B (80.8%)80.8
5D (71.7%)71.7
6F (38.1%)38.1
7C (78.6%)78.6
8C (78.0%)78
Sheet3
Cell Formulas
RangeFormula
B2:B8B2=MID($A2,FIND("(",$A2)+1,4)*1


Of course, this doesn't work for values under 10%. It can be adjusted or just use Kevin's suggestion.
 
Upvote 0
Here is an alternative solution with Power Query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Inserted Text Between Delimiters" = Table.AddColumn(Source, "Text Between Delimiters", each Text.BetweenDelimiters([Grade Summary], "(", ")"), type text),
    #"Replaced Value" = Table.ReplaceValue(#"Inserted Text Between Delimiters","%","",Replacer.ReplaceText,{"Text Between Delimiters"})
in
    #"Replaced Value"
 
Upvote 0
How about this:

Book1
AB
1Grade SummaryGrade Score Raw
2A (100.0%)100
3B (85.2%)85.2
4B (80.8%)80.8
5D (71.7%)71.7
6F (38.1%)38.1
7C (78.6%)78.6
8C (78.0%)78
Sheet3
Cell Formulas
RangeFormula
B2:B8B2=MID($A2,FIND("(",$A2)+1,4)*1


Of course, this doesn't work for values under 10%. It can be adjusted or just use Kevin's suggestion.
This formula worked for me...
= MID (E8 , SEARCH ( "(", E8 ) + 1 , SEARCH ( ")" , E8 ) - SEARCH ( "(" , E8 ) - 1 )

But now I'm trying to only calculate if E8 is not blank...which I can't seem to do.
 
Upvote 0
Excel Formula:
=IF(A2<>"",MID(A2, SEARCH("(", A2)+1, SEARCH("%", A2) - SEARCH("(", A2) -1),"")
 
Upvote 0
This formula worked for me...
= MID (E8 , SEARCH ( "(", E8 ) + 1 , SEARCH ( ")" , E8 ) - SEARCH ( "(" , E8 ) - 1 )

But now I'm trying to only calculate if E8 is not blank...which I can't seem to do.
Like this:
Book1
EF
1
2
3
4
5
6
7Grade SummaryGrade Score Raw
8A (100.0%)100
9B (85.2%)85.2
10B (80.8%)80.8
11D (71.7%)71.7
12F (38.1%)38.1
13C (78.6%)78.6
14C (78.0%)78
15F (9%)9
16 
17A (95.5%)95.5
Sheet3
Cell Formulas
RangeFormula
F8:F17F8=IF(E8<>"",MID($E8,FIND("(",$E8)+1,FIND("%",E8)-FIND("(",E8)-1)*1,"")
 
Upvote 0
I need a formula that will automatically populate the 2nd column like this...

B (85.2%)85.2
This formula worked for me...
= MID (E8 , SEARCH ( "(", E8 ) + 1 , SEARCH ( ")" , E8 ) - SEARCH ( "(" , E8 ) - 1 )
That formula doesn't quite return the result you listed originally. It would return 85.2% for that sample data not just 85.2 as shown in post 1.

Also, just confirming that you are happy to return a text value not a number value?

Assuming a text value is acceptable, then if your sample data is representative, you could use the column F formula below.
If the text before the parentheses can vary in length then try the column G formula.

If numbers are wanted & sample representative, col H
If the text before the parentheses can vary in length then try col I

23 12 07.xlsm
EFGHI
8A (100.0%)100.0%100.0%100100
9B (85.2%)85.2%85.2%85.285.2
10    
11C (2%)2%2%22
Extract Num
Cell Formulas
RangeFormula
F8:F11F8=SUBSTITUTE(MID(E8,4,20),")","")
G8:G11G8=IF(E8="","",REPLACE(LEFT(E8,LEN(E8)-1),1,FIND("(",E8),""))
H8:H11H8=IF(E8="","",-100*MID(E8,3,20))
I8:I11I8=IF(E8="","",-100*MID(E8,FIND("(",E8),20))
 
Upvote 0
Or if you wanted to return numerical values
Excel Formula:
=IF(A2<>"",MID(A2, SEARCH("(", A2)+1, SEARCH("%", A2) - SEARCH("(", A2) -1)*1,"")
 
Upvote 0
Solution

Forum statistics

Threads
1,223,882
Messages
6,175,166
Members
452,615
Latest member
bogeys2birdies

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