Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 22 Sep 2008 13:23:01 -0700, johnrb7865
wrote: Hi, does anyone know how I would pull numbers out of a string of text? For example, the text: Prepare Culvert Pipe (30 Inch), I need a formula to display just the "30". The text strings will vary so I cannot use MID to pull out text at certain spots. Any thoughts? Thanks, John If the value will be the first integer in the string, then: ========================== Option Explicit Function Nums(str As String) As Double Dim re As Object, mc As Object Set re = CreateObject("vbscript.regexp") re.Pattern = "\d+" If re.test(str) = True Then Set mc = re.Execute(str) Nums = mc(0).Value End If End Function =========================== If the value is might be a decimal number or a fraction, then we would need to change re.pattern. --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
finding case numbers | Excel Worksheet Functions | |||
Finding Duplicate Numbers | Excel Discussion (Misc queries) | |||
Finding numbers or numbers and dashes in text | Excel Programming | |||
Finding Row Numbers Within the RangeName | Excel Programming | |||
finding numbers | New Users to Excel |