Extract number from parenthesis

excel_training_wheels

Board Regular
Joined
Aug 25, 2005
Messages
193
Hi--

Even though I have training wheels on, I almost have the formula I need, just need a bit of help. :)

What can I enter to extract the number, of varying length....

(111 @asb)
(123546 @hjd)
(2 @bbb)
(09 @tuy)

I was using the RIGHT function and getting close, but not exactly there. Thanks for your help!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
excel_training_wheels said:
Hi--

Even though I have training wheels on, I almost have the formula I need, just need a bit of help. :)

What can I enter to extract the number, of varying length....

(111 @asb)
(123546 @hjd)
(2 @bbb)
(09 @tuy)

I was using the RIGHT function and getting close, but not exactly there. Thanks for your help!

=SUBSTITUTE(LEFT(A2,SEARCH(" ",A2)-1),"(","")
 
Upvote 0
Hi
Ozgrid has a beautiful routine for this;
insert the following module

and then if you for example had 123frg567 in cell A1, just use the formula
=extractNumber(A1) wherever you want it


Function ExtractNumber(rCell As Range)
Dim lCount As Long, l As Long
Dim sText As String
Dim lNum As String
sText = rCell
For lCount = Len(sText) To 1 Step -1
If IsNumeric(Mid(sText, lCount, 1)) Then
l = l + 1
lNum = Mid(sText, lCount, 1) & lNum
End If
If l = 1 Then lNum = CInt(Mid(lNum, 1, 1))
Next lCount
ExtractNumber = CLng(lNum)
End Function
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

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