View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Kevin B Kevin B is offline
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