Rick
Re this code:
Rich (BB code):For Each vNum In Array(13, 5, 3, 3, 2) txt = Replace(txt, String(vNum, ";"), ";") Next
I can see in the first iteration it builds a string of 13 semi colons, and replaces it with one.
Next iteration a string of 5 semi colons, replacing it with one, etc.
I'm interested in how you figure out the number sequence.
[edit]
it's OK, I see it is a Fibonacci sequence. [edit] Or is it?
Thank you guys! So many working ways
I would be willing to bet the OP will not run into this limit, but just letting you know, your code fails for 39, and fails spottily for more than 39, consecutive semicolons. I guess you are using the 5-4-3-2 pattern of repeated semicolons because it is easy to remember, however, your code would work up to the same 39 consecutive semicolon limit if you changed the pattern to 5-3-2-2 (and saved your fingers from having to type those two extra semicolons). Intersestingly, using the Evaluate function the way you did is three times faster than using the Range's built-in Replace method... I found that kind of surprising myself.Code:Sub ReplaceSemicolonDupes() ' hiker95, 04/09/2015, ME847584 With Range("A1", Range("A" & Rows.Count).End(xlUp)) .Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","";;;;;"","";""),"""")") .Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","";;;;"","";""),"""")") .Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","";;;"","";""),"""")") .Value = Evaluate("IF(ROW(),SUBSTITUTE(" & .Address & ","";;"","";""),"""")") End With End Sub
Intersestingly, using the Evaluate function the way you did is three times faster than using the Range's built-in Replace method... I found that kind of surprising myself.