Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello everyone!!
Need to create a custum function in Excel that will allow me to extra a series of numbers from a string. The string will have a fix format, so this should facilitate the process. The numbers im looking for are always going to be serounded by brakets. Ex: test(234)test2 From this example and using the brakets as guidlines, what type of code would be able to extract the '234' number. Thx for your hlp, Patrick |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Why VBA? This formula should do what you need. It assumes the text is in Cell
A1 =VALUE(MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1)) -- HTH... Jim Thomlinson "Patrick" wrote: Hello everyone!! Need to create a custum function in Excel that will allow me to extra a series of numbers from a string. The string will have a fix format, so this should facilitate the process. The numbers im looking for are always going to be serounded by brakets. Ex: test(234)test2 From this example and using the brakets as guidlines, what type of code would be able to extract the '234' number. Thx for your hlp, Patrick |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Patrick,
You colud use the following formula: =MID(A2,FIND("(",A2,1)+1,FIND(")",A2,1)-FIND("(",A2,1)-1) Assuming data starts in A2, place in required column and copy down. OR =findNum(b1) Function findNum(rng) findNum = Mid(rng, InStr(1, rng, "(") + 1, InStr(1, rng, ")") - InStr(1, rng, "(") - 1) End Function "Patrick" wrote: Hello everyone!! Need to create a custum function in Excel that will allow me to extra a series of numbers from a string. The string will have a fix format, so this should facilitate the process. The numbers im looking for are always going to be serounded by brakets. Ex: test(234)test2 From this example and using the brakets as guidlines, what type of code would be able to extract the '234' number. Thx for your hlp, Patrick |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
That will work for me to, thx alot Jim.....
"Jim Thomlinson" wrote: Why VBA? This formula should do what you need. It assumes the text is in Cell A1 =VALUE(MID(A1,FIND("(",A1)+1,FIND(")",A1)-FIND("(",A1)-1)) -- HTH... Jim Thomlinson "Patrick" wrote: Hello everyone!! Need to create a custum function in Excel that will allow me to extra a series of numbers from a string. The string will have a fix format, so this should facilitate the process. The numbers im looking for are always going to be serounded by brakets. Ex: test(234)test2 From this example and using the brakets as guidlines, what type of code would be able to extract the '234' number. Thx for your hlp, Patrick |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Patrick. The difference between Topper's formula and mine is that mine
returns a number, while Topper's returns a string. Since you did not specify just pick the one that works for you... -- HTH... Jim Thomlinson "Toppers" wrote: Patrick, You colud use the following formula: =MID(A2,FIND("(",A2,1)+1,FIND(")",A2,1)-FIND("(",A2,1)-1) Assuming data starts in A2, place in required column and copy down. OR =findNum(b1) Function findNum(rng) findNum = Mid(rng, InStr(1, rng, "(") + 1, InStr(1, rng, ")") - InStr(1, rng, "(") - 1) End Function "Patrick" wrote: Hello everyone!! Need to create a custum function in Excel that will allow me to extra a series of numbers from a string. The string will have a fix format, so this should facilitate the process. The numbers im looking for are always going to be serounded by brakets. Ex: test(234)test2 From this example and using the brakets as guidlines, what type of code would be able to extract the '234' number. Thx for your hlp, Patrick |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No real need for code:
=--MID(LEFT(A1,FIND(")",A1)-1),FIND("(",A1)+1,255) where the -- coerces the Text returned by MID() to an XL number. However, if you need a UDF: Public Function ExtractNumberInParens( _ ByVal sInput As String) As Variant Dim sTemp As String If sInput Like "*(*)*" Then sTemp = Mid(Left(sInput, InStr(sInput, ")") - 1), _ InStr(sInput, "(") + 1) If IsNumeric(sTemp) Then ExtractNumberInParens = CDbl(sTemp) End If End If If IsEmpty(ExtractNumberInParens) Then _ ExtractNumberInParens = CVErr(xlErrValue) End Function In article , "Patrick" wrote: Hello everyone!! Need to create a custum function in Excel that will allow me to extra a series of numbers from a string. The string will have a fix format, so this should facilitate the process. The numbers im looking for are always going to be serounded by brakets. Ex: test(234)test2 From this example and using the brakets as guidlines, what type of code would be able to extract the '234' number. Thx for your hlp, Patrick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Extracting Info From Within A Text String | Excel Worksheet Functions | |||
Extracting info from web pages | Excel Discussion (Misc queries) | |||
Extracting info to new tables | Excel Discussion (Misc queries) | |||
Extracting info from a database | Excel Programming | |||
extracting info the best way | Excel Programming |