View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Extract text on right of various length from cells

On Thu, 2 Jul 2009 00:40:20 -0400, "Rick Rothstein"
wrote:

Heh, heh... you made me go back and look at my UDF again... and I don't
think I need the WorksheetFunction.Trim call either.

Function RemDigitsPart(s As String) As String
Dim X As Long
Dim Parts() As String
Parts = Split(s, "(")
For X = 1 To UBound(Parts)
If X 1 Then RemDigitsPart = RemDigitsPart & ", "
RemDigitsPart = RemDigitsPart & Trim(Split(Parts(X), ")")(0))
Next
End Function

However, my UDF acts differently than yours for multiple spaces within the
text itself... I leave it there whereas you remove it. I can make the
argument for removing any extraneous outer spaces as the purpose of the UDF
seems to be to make a comma delimited list of the text located between the
parentheses and they would just "ugly up" the list; however, if there were
multiple internal spaces in the text, should we really be removing them (the
question being, why were they there in the first place... on purpose or by
mistake)? If the answer is yes, the multiple internal spaces should be
collapsed down to a single space, then in my code above, just swap out the
VBA Trim function for the Worksheet one. For the OP... that just means you
prepend WorksheetFunction. (notice the ending dot) onto the Trim function
call above.


As frequently is the case, it depends on reading between the lines of the OP's
incomplete specifications.
--ron