Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Duplicate phrases in one cell

On Mon, 18 May 2009 12:19:29 +0100, "Peter T" <peter_t@discussions wrote:

I don't fully follow the objective but based solely on your examples, it
looks like all you need to do is compare the left half with the right half.
You could do that with a VBA (could be a UDF) or with a simple formula, eg

=IF(LEFT(A1,LEN(A1)/2)=RIGHT(A1,LEN(A1)/2),LEFT(A1,LEN(A1)/2),A1)


Very simple, and neat.
--ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Duplicate phrases in one cell

On May 18, 1:45*pm, Ron Rosenfeld wrote:
On Mon, 18 May 2009 12:19:29 +0100, "Peter T" <peter_t@discussions wrote:
I don't fully follow the objective but based solely on your examples, it
looks like all you need to do is compare the left half with the right half.
You could do that with a VBA (could be a UDF) or with a simple formula, eg


=IF(LEFT(A1,LEN(A1)/2)=RIGHT(A1,LEN(A1)/2),LEFT(A1,LEN(A1)/2),A1)


Very simple, and neat.
--ron



Excellent solutions! I am happy to report that these work perfectly
for what I was wishing to do. I want to thank you guys very much for
the ingenuity.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Duplicate phrases in one cell

"Ron Rosenfeld" wrote in message
=IF(LEFT(A1,LEN(A1)/2)=RIGHT(A1,LEN(A1)/2),LEFT(A1,LEN(A1)/2),A1)


Very simple, and neat.
--ron


Why thank you Ron.

Yours is very clever :-)

Regards,
Peter T


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Duplicate phrases in one cell

On Tue, 19 May 2009 11:34:01 +0100, "Peter T" <peter_t@discussions wrote:

Why thank you Ron.

Yours is very clever :-)

Regards,
Peter T


Mine uses Regular Expressions, and conceptually is doing the same thing as
yours. But a formulaic expression is usually much faster.

The only advantage to mine might be easy to change if the OP's requirements are
a bit different than posted.
--ron
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Duplicate phrases in one cell

"Ron Rosenfeld" wrote in message

Mine uses Regular Expressions, and conceptually is doing the same thing as
yours.
The only advantage to mine might be easy to change if the OP's
requirements are
a bit different than posted.


Would you care to explain how (if left-half = right-half)

re.Pattern = "^(.*)(\1)$"
mc = re.Execute(theString)

puts the left half in this
mc(0).submatches(1)

Regards,
Peter T




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default Duplicate phrases in one cell

On Tue, 19 May 2009 22:26:31 +0100, "Peter T" <peter_t@discussions wrote:

Would you care to explain how (if left-half = right-half)

re.Pattern = "^(.*)(\1)$"
mc = re.Execute(theString)

puts the left half in this
mc(0).submatches(1)

Regards,
Peter T


I can try.

Actually, its the right half that's in mc(0).submatches(1), but since the right
and left halves are the same, it doesn't matter. The left half would be in
mc(0).submatches(0).

The pattern defines what is matched as follows:

------------------------
Paired phrases

^(.*)(\1)$

Assert position at the beginning of the string «^»
Match the regular expression below and capture its match into backreference
number 1 «(.*)»
Match any single character that is not a line break character «.*»
Between zero and unlimited times, as many times as possible, giving back
as needed (greedy) «*»
Match the regular expression below and capture its match into backreference
number 2 «(\1)»
Match the same text as most recently matched by capturing group number 1
«\1»
Assert position at the end of the string (or before the line break at the end
of the string, if any) «$»


Created with RegexBuddy
----------------------------

Since the pattern includes the beginning and end of the line, it will only
match if the left half = the right half.

Then it's just a matter of returning one, or the other.

See these references regarding Regular Expressions. They are from my
bookmarks; hopefully some of them are still good!

Regular Expressions
http://www.regular-expressions.info/reference.html
http://support.microsoft.com/default...02&Product=vbb
http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx
http://msdn2.microsoft.com/en-us/library/ms974619.aspx
http://www.regex-guru.info/
--ron
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Duplicate phrases in one cell

Thanks for that Ron, it helps.
One of these days I'll try and get to grips with it, might need to get into
a certain frame of mind first !

Regards,
Peter T


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicate phrases in one cell Ron Rosenfeld Excel Programming 0 May 18th 09 06:15 PM
Finding Duplicate Phrases in a File Mis Excel Worksheet Functions 2 June 29th 06 12:39 AM
How to insert random phrases Jooky Excel Worksheet Functions 1 January 15th 06 06:16 PM
How to Replace Numbers with Phrases Jerry Arnone, PMP Excel Discussion (Misc queries) 1 June 29th 05 02:00 PM
How to Replace Numbers with Phrases Jerry Arnone, PMP Excel Discussion (Misc queries) 0 June 29th 05 12:37 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"