LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Replace using Do loop

My text has duplicate characters in the same cell, let's say the
character is "a". I want to find and replace all duplicates until
there is never two a's in a row, so

baaaat
baaat
baat
bat

becomes

bat
bat
bat
bat

Should I use a Do While or Do Until loop for this? As in...

Do
Selection.Replace What:="aa", Replacement:="a", LookAt:=xlPart,
SearchOrder:=xlByRows, MatchCase:=False
Loop Until [?????]

Seems like using Excel's built-in Replace function would be the
simplest and have the fastest execution. But what should be the
condition which causes the loop to exit? What happens when a Replace
call finds nothing? Thanks.

(P.S. the duplicate characters are not letters, they're stuff like {
and ^, so don't worry about messing up words like aardvark, as the
above example would.)

 
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
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Find & Replace / Loop & Vlookup thom hoyle Excel Programming 5 June 25th 05 12:56 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
Replace Loop Darrell[_4_] Excel Programming 1 November 21st 03 04:49 PM


All times are GMT +1. The time now is 09:41 PM.

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

About Us

"It's about Microsoft Excel"