View Single Post
  #26   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Select specific text in cell

On Sat, 16 Feb 2008 14:52:16 -0500, "Rick Rothstein \(MVP - VB\)"
wrote:

Expanding -- it would certainly be possible for a parser in which
the "\" preceding the filename was optional


And I meant to my last post that doing this, or any other customization of
parsing, would be fruitless without the OP coming back and filling us in on
what (if any) restrictions exist on his filenames, the descriptions or the
delimiter separating them.

By the way, IF we had to cater to a 'backslashless' path, and IF the
delimiter between the filename and description is in fact a
space/dash/space, the one-liner would become slightly uglier ...

Function fn(str As String) As String
fn = Trim(Split(Split(Replace(str, ":", "\"), "\") _
(UBound(Split(Replace(str, ":", "\"), "\"))), " - ")(0))
End Function

Rick


This, too, will work so long as there is no hyphen within description, but I
couldn't make a one-liner out of it.

==========================
Option Explicit
Function fn(str As String) As String
Dim s1() As String
s1 = Split(Split(str, "\")(UBound(Split(str, "\"))), "-")
ReDim Preserve s1(UBound(s1) - 1)
fn = Join(s1, "-")
End Function
==============================
--ron