View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mark B. Mark B. is offline
external usenet poster
 
Posts: 19
Default Deleting characters after 3rd occurence of a string

Thanks, Ron! Worked like a charm.
--
Thanks,
Mark


"Ron Rosenfeld" wrote:

On Mon, 8 Sep 2008 14:18:00 -0700, Mark b.
wrote:

Trying to systematically delete all characters after the 3rd occurence of a
string and not having much luck with the Len, right and substitute commands.

In a region of cells, some of the data contains values separated by the '/'
character. when a cell contains the '/' character 3 (or more) times, I'd
like to remove that character and all characters to the right of it.

Thus:

apple/banana/cherry/date would get truncated down to apple/banana/cherry
animal/vegetable would remain animal/vefetable


thoughts?



=REPLACE(A1,FIND(CHAR(1),SUBSTITUTE(A1&CHAR(1),"/",CHAR(1),3)),255,"")

--ron