View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Rick Rothstein \(MVP - VB\)[_429_] Rick Rothstein \(MVP - VB\)[_429_] is offline
external usenet poster
 
Posts: 1
Default How do I separate numbers?

That returns 1 for an entry of 1a2/3 (I'm guessing it is quitting at the
first non-digit)... I would think it should return the original text if the
text doesn't meet the pattern number/slash/number. Here is my non-RegEx
attempt for a UDF...

Function GetNumberBeforeSlash(Source As Variant) As Variant
If Not Left(Source, InStr(Source & "/", "/") - 1) Like "*[!0-9]*" And _
Source Like "?*/*" And Not Source Like "*/*/*" Then
GetNumberBeforeSlash = Left(Source, InStr(Source, "/") - 1)
Else
GetNumberBeforeSlash = Source
End If
End Function

Rick


"Bernd P" wrote in message
...
Hello,

ok ok, but just for the fun of it:
=regexpreplace(A1,"^(\d+).*$","$1")

The UDF is he
http://www.sulprobil.com/html/regexp.html

Regards,
Bernd