LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Extract numbers from a string ?

On Thu, 3 Mar 2005 11:49:01 -0800, "Jello"
wrote:

I have serached the String class but cant see any function that can identify
integers within a string ?
I want to replace all instances of "Mystringwith10integer" with
"Mystringwith11integer" etc.
Is there such a funtion ?

Many thanks, Jello


Something like:

==============
Sub IncrNumInStr()
Const str = "Mystringwith10integer"

Dim i As Long
Dim FirstPart As String
Dim LastPart As String
Dim Num As Long

For i = 1 To Len(str)
If IsNumeric(Mid(str, i, 1)) Then
FirstPart = Left(str, i - 1)
Num = Val(Mid(str, i, 255))
Exit For
End If
Next i

For i = i To Len(str)
If Not IsNumeric(Mid(str, i, 1)) Then
LastPart = Mid(str, i, 255)
Exit For
End If
Next i

Debug.Print FirstPart & Num + 1 & LastPart

End Sub
==================
--ron
 
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
Extract numbers from a string of text Huber57 Excel Discussion (Misc queries) 0 May 27th 10 09:53 PM
Extract numbers from a string of text Mike H Excel Discussion (Misc queries) 0 May 27th 10 09:48 PM
HOW DO I EXTRACT NUMBERS FROM TEXT STRING AndyF Excel Discussion (Misc queries) 7 August 14th 08 02:37 PM
extract numbers from a string Dave Excel Worksheet Functions 3 August 7th 08 09:43 PM
Only extract numbers from a string of text Lost in Microbiology Excel Discussion (Misc queries) 4 October 22nd 07 03:39 PM


All times are GMT +1. The time now is 09:41 AM.

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"