ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Seperate numbers from letters (https://www.excelbanter.com/excel-programming/285672-seperate-numbers-letters.html)

Jamal[_2_]

Seperate numbers from letters
 
I have a column within a list which is made up of numbers
and letters. Most of the time they are in blocks and I can
sepearte them using a custom function. However,
occassionally numbers are mixed with letters
e.g "And24this253". How can I seperate the numbers out of
this but keep the same order as they appear?

Thank you so much for your help.

Don Guillett[_4_]

Seperate numbers from letters
 
You might find something here

http://tinyurl.com/zo6o

--
Don Guillett
SalesAid Software

"Jamal" wrote in message
...
I have a column within a list which is made up of numbers
and letters. Most of the time they are in blocks and I can
sepearte them using a custom function. However,
occassionally numbers are mixed with letters
e.g "And24this253". How can I seperate the numbers out of
this but keep the same order as they appear?

Thank you so much for your help.




Ron Rosenfeld

Seperate numbers from letters
 
On Wed, 17 Dec 2003 08:33:08 -0800, "Jamal"
wrote:

I have a column within a list which is made up of numbers
and letters. Most of the time they are in blocks and I can
sepearte them using a custom function. However,
occassionally numbers are mixed with letters
e.g "And24this253". How can I seperate the numbers out of
this but keep the same order as they appear?

Thank you so much for your help.


Well, since this is a programming group, here are two UDF's to accomplish this:


================
Function GetValue(str)
Dim N As Integer, i As String
i = ""
For N = 1 To Len(str)
If IsNumeric(Mid(str, N, 1)) Then
i = i & Mid(str, N, 1)
If Mid(str, N + 1, 1) = "." Then i = i & "."
End If
Next
If i = "" Then
GetValue = i
Exit Function
End If
GetValue = CDbl(i)
End Function
'-----------------------
Function GetLtrs(str) As String

GetLtrs = ""

Dim N As Integer
For N = 1 To Len(str)
If Not (IsNumeric(Mid(str, N, 1))) Then GetLtrs = GetLtrs & Mid(str, N,
1)
Next
End Function
=============================


--ron


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com