Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Strings and numbers in cells

Is there a way to make Excel only recognise numbers in a cell when the cell
contains both numbers and a string?

lespal
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Strings and numbers in cells

The following UDF might do what you want it to. It loops through a string
value and concatenates numeric strings and returns the result as a long
integer.

Function ReturnNums(StringVal) As Long


Dim intLen As Integer
Dim i As Integer
Dim strReturnVal As String
Dim strChar As String

intLen = Len(StringVal)


For i = 1 To intLen
strChar = Mid(StringVal, i, 1)
If IsNumeric(strChar) Then strReturnVal = strReturnVal & strChar
Next i

If Len(strReturnVal) = 0 Then
ReturnNums = 0
Else
ReturnNums = CLng(strReturnVal)
End If


End Function
--
Kevin Backmann


"lespal" wrote:

Is there a way to make Excel only recognise numbers in a cell when the cell
contains both numbers and a string?

lespal

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
How can I total just the numbers in a column and ignore non-numeric strings? Bud Excel Worksheet Functions 1 June 30th 06 08:02 AM
how to extract decimal numbers from alphanumeric strings in Excel Old Tone Excel Discussion (Misc queries) 13 March 23rd 06 03:49 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
2 more questions about extracting numbers from text strings andy from maine Excel Discussion (Misc queries) 0 March 28th 05 09:47 PM
Extract numbers from strings Stan Altshuller Excel Worksheet Functions 6 February 17th 05 09:33 PM


All times are GMT +1. The time now is 02:42 AM.

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

About Us

"It's about Microsoft Excel"