View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\) Rick Rothstein \(MVP - VB\) is offline
external usenet poster
 
Posts: 2,202
Default how do i separate numbers and text in a cell?

hi, i tried the macro however all numbers are printed, i would go for such
a
solution as T Valko created as this can be placed in a separate column
which
gives great performance. the macro has less performance, i have to check
about 30.000 rows.


Give this macro function a try...

Function ExtractNumber(ByVal StringIn As String) As Single
On Error Resume Next
StringIn = Replace(StringIn, ")", " )")
ExtractNumber = CSng(Split(Trim$(Split(StringIn, "(")(1)))(0))
End Function

As long as the String value you feed into it has the number you want within
parentheses (what you call brackets) and the number is followed by either a
space or a closing parenthesis; that is, your number can't look like this...
(5.5hrs) where there is no space between the number and any numeric
description, then the function will return the number (as a Single, but you
can change that if you wish).

Rick