Extract numerical value from text string after : within text string

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
Cell A1 = "Text123 : String is 34"

I am trying to extract the 34 from the text string in A1 but I do not want to extract the 123....

I tried the below. Failed miserably.

Code:
=MID((MID(A3,FIND(":",A3)+3,LEN(A3))),MATCH(TRUE,ISNUMBER(1*MID((MID(A3,FIND(":",A3)+3,LEN(A3))),ROW($1:$101),1)),0),COUNT(1*MID((MID(A3,FIND(":",A3)+3,LEN(A3))),ROW($1:$101),1)))
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,836
Office Version
  1. 2010
Platform
  1. Windows
=mid(substitute(a1, " ", "|", len(a1) - len(substitute(a1, " ", ""))), find("|", substitute(a1, " ", "|", len(a1) - len(substitute(a1, " ", "")))) + 1, 99)
 
Upvote 0

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
38,154
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
Cell A1 = "Text123 : String is 34"

I am trying to extract the 34 from the text string in A1 but I do not want to extract the 123....

I tried the below. Failed miserably.

Code:
=MID((MID(A3,FIND(":",A3)+3,LEN(A3))),MATCH(TRUE,ISNUMBER(1*MID((MID(A3,FIND(":",A3)+3,LEN(A3))),ROW($1:$101),1)),0),COUNT(1*MID((MID(A3,FIND(":",A3)+3,LEN(A3))),ROW($1:$101),1)))
One example is usually not enough to clue us into what you data looks like... a representative set of samples showing the various ways in which the text can appear would be better. If the number you want is always at the end of the text (like your example shows), then you can use this formula to get it...

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))
 
Upvote 0

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
Range,

If you want to extract the number to do some calculations (the YELLOW cells, cells B1, and C1), how about something like this?


Excel 2007
ABCD
1Text123 : String is 34343468
2Text123 : String is 3434340
Sheet1
Cell Formulas
RangeFormula
B1=0+TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))
B2=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),LEN(A2)))
C1=0+MID(SUBSTITUTE(A1, " ", "|", LEN(A1) - LEN(SUBSTITUTE(A1, " ", ""))), FIND("|", SUBSTITUTE(A1, " ", "|", LEN(A1) - LEN(SUBSTITUTE(A1, " ", "")))) + 1, 99)
C2=MID(SUBSTITUTE(A2, " ", "|", LEN(A2) - LEN(SUBSTITUTE(A2, " ", ""))), FIND("|", SUBSTITUTE(A2, " ", "|", LEN(A2) - LEN(SUBSTITUTE(A2, " ", "")))) + 1, 99)
D1=SUM(B1:C1)
D2=SUM(B2:C2)
 
Upvote 0

Range

Board Regular
Joined
Nov 13, 2010
Messages
140
Wow Guys, Thank you soo much. This information is soo useful to me and currently I dont have time to fully break it down but over the next couple of months I will be and learning to do this myself properly. In the meantime I will just be copying and pasting your help - thanks soo much again.

One example is usually not enough to clue us into what you data looks like... a representative set of samples showing the various ways in which the text can appear would be better. If the number you want is always at the end of the text (like your example shows), then you can use this formula to get it...

=TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))

Appreciate the feedback Rick, I have lots of outstanding issues on a spreadsheet I am working on for a friend. I will provide better detailed first posts in future.

Range,

If you want to extract the number to do some calculations (the YELLOW cells, cells B1, and C1), how about something like this?

Excel 2007
ABCD
1Text123 : String is 34343468
2Text123 : String is 3434340

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B1=0+TRIM(RIGHT(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)))
C1=0+MID(SUBSTITUTE(A1, " ", "|", LEN(A1) - LEN(SUBSTITUTE(A1, " ", ""))), FIND("|", SUBSTITUTE(A1, " ", "|", LEN(A1) - LEN(SUBSTITUTE(A1, " ", "")))) + 1, 99)
D1=SUM(B1:C1)
B2=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",LEN(A2))),LEN(A2)))
C2=MID(SUBSTITUTE(A2, " ", "|", LEN(A2) - LEN(SUBSTITUTE(A2, " ", ""))), FIND("|", SUBSTITUTE(A2, " ", "|", LEN(A2) - LEN(SUBSTITUTE(A2, " ", "")))) + 1, 99)
D2=SUM(B2:C2)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
Thanks again
 
Upvote 0

hiker95

Well-known Member
Joined
Apr 8, 2009
Messages
17,649
Range,

Thanks for the feedback.

You are very welcome. Glad we could help.

And, come back anytime.
 
Upvote 0

Forum statistics

Threads
1,195,848
Messages
6,011,946
Members
441,656
Latest member
oo3

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
Top