Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default finding numbers

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
finding case numbers em Excel Worksheet Functions 2 August 24th 09 02:31 PM
Finding Duplicate Numbers chadhable Excel Discussion (Misc queries) 1 May 16th 08 12:47 AM
Finding numbers or numbers and dashes in text [email protected] Excel Programming 6 April 2nd 07 12:10 PM
Finding Row Numbers Within the RangeName Goofy Excel Programming 4 October 19th 06 09:42 AM
finding numbers flat6 New Users to Excel 2 February 17th 05 10:17 PM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"