Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to crop only numbers from a string?

function should return number 41 from string:
"vivaldi - 4 - seasons - movement/1"


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default How to crop only numbers from a string?

Maybe:

Sub GetIt()
Dim str As String
str = "vivaldi - 4 - seasons - movement/1"
MsgBox num(str)

End Sub

Function num(inpt As String)
Dim i As Integer
For i = 1 To Len(inpt)
If IsNumeric(Mid(inpt, i, 1)) Then
num = num & Mid(inpt, i, 1)
End If
Next i
num = CLng(num)
End Function

Regards
Rowan

serdar wrote:
function should return number 41 from string:
"vivaldi - 4 - seasons - movement/1"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to crop only numbers from a string?

thanks for ur effort to code the entire function. seems u r real fast and
pro. just IsNumeric( ) would be enough also but u spend ur time to write
all.

well, i am assuming IsNumeric( ) crops only 1234567890



"Rowan Drummond" , haber iletisinde sunlari
...
Maybe:

Sub GetIt()
Dim str As String
str = "vivaldi - 4 - seasons - movement/1"
MsgBox num(str)

End Sub

Function num(inpt As String)
Dim i As Integer
For i = 1 To Len(inpt)
If IsNumeric(Mid(inpt, i, 1)) Then
num = num & Mid(inpt, i, 1)
End If
Next i
num = CLng(num)
End Function

Regards
Rowan

serdar wrote:
function should return number 41 from string:
"vivaldi - 4 - seasons - movement/1"



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default How to crop only numbers from a string?

IsNumeric returns true or false based on the input so:
? isnumeric(5) True
? isnumeric("b") False
The function does the cropping based on these results for each character
in the string.

Regards
Rowan

serdar wrote:
thanks for ur effort to code the entire function. seems u r real fast and
pro. just IsNumeric( ) would be enough also but u spend ur time to write
all.

well, i am assuming IsNumeric( ) crops only 1234567890



"Rowan Drummond" , haber iletisinde sunlari
...

Maybe:

Sub GetIt()
Dim str As String
str = "vivaldi - 4 - seasons - movement/1"
MsgBox num(str)

End Sub

Function num(inpt As String)
Dim i As Integer
For i = 1 To Len(inpt)
If IsNumeric(Mid(inpt, i, 1)) Then
num = num & Mid(inpt, i, 1)
End If
Next i
num = CLng(num)
End Function

Regards
Rowan

serdar wrote:

function should return number 41 from string:
"vivaldi - 4 - seasons - movement/1"




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
crop away the letters Fan924 Excel Discussion (Misc queries) 4 June 15th 09 05:51 PM
crop AutoCAD object jerryk571 Excel Discussion (Misc queries) 0 January 21st 09 06:33 PM
crop spreadsheet bekwud New Users to Excel 11 September 17th 06 10:35 PM
Converting String numbers into real numbers Werner[_11_] Excel Programming 1 June 27th 05 09:41 PM
Converting String numbers into real numbers Jean-Jérôme Doucet via OfficeKB.com Excel Programming 2 June 27th 05 03:30 PM


All times are GMT +1. The time now is 07:56 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"