PC Review


Reply
Thread Tools Rate Thread

Deleting characters after 3rd occurence of a string

 
 
Mark b.
Guest
Posts: n/a
 
      8th Sep 2008
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?


--
Thanks,
Mark
 
Reply With Quote
 
 
 
 
Ron Rosenfeld
Guest
Posts: n/a
 
      8th Sep 2008
On Mon, 8 Sep 2008 14:18:00 -0700, Mark b. <(E-Mail Removed)>
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
 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      8th Sep 2008
=IF(LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))>2,LEFT(A1,FIND("/",A1,FIND("/",A1,FIND("/",A1)+1)+1)-1),A1)

--
__________________________________
HTH

Bob

"Mark b." <(E-Mail Removed)> wrote in message
news:898D0AB9-A132-4E16-BAF0-(E-Mail Removed)...
> 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?
>
>
> --
> Thanks,
> Mark



 
Reply With Quote
 
Mark b.
Guest
Posts: n/a
 
      9th Sep 2008
Thanks, Ron! Worked like a charm.
--
Thanks,
Mark


"Ron Rosenfeld" wrote:

> On Mon, 8 Sep 2008 14:18:00 -0700, Mark b. <(E-Mail Removed)>
> 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
>

 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      9th Sep 2008
On Tue, 9 Sep 2008 07:07:01 -0700, Mark b. <(E-Mail Removed)>
wrote:

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


You're welcome. Glad to help. Thanks for the feedback.
--ron
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
find first occurence of multiple characters tshad Microsoft VB .NET 6 19th Sep 2008 05:17 PM
How to count occurence of multiple characters in a cell =?Utf-8?B?TUxL?= Microsoft Excel Worksheet Functions 4 9th Mar 2007 12:51 AM
Deleting string of characters Roger Bedford Microsoft Outlook Discussion 3 16th Sep 2004 08:07 PM
Re: Replacing occurence of string in another string JE McGimpsey Microsoft Excel Programming 0 11th Mar 2004 02:22 PM
Re: Replacing occurence of string in another string Frank Kabel Microsoft Excel Programming 0 11th Mar 2004 02:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:04 PM.