1

I have a string that looks like this in one cell:

Col1Col2Col3Col4Col5

it goes all the way to Col100.

I want to use one formula without VBA and add a comma in between the Col to make the text look like this:

Col1,Col2,Col3,Col4,Col5

again all the way to Col100.

I'm thinking some kind of find replace function in excel?

1 Answer 1

3

As a formula:

=LEFT(A1,1)&SUBSTITUTE(MID(A1,2,1024),"Col",",Col")

1024 is an assumed maximum number of characters in a cell.

If not every cell contains this text then you could only substitute if the cell begins with "Col":

=IF(LEFT(A1,3)="Col",LEFT(A1,1)&SUBSTITUTE(MID(A1,2,255),"Col",",Col"),A1)
Sign up to request clarification or add additional context in comments.

3 Comments

sweet. thanks. quick question, what is the "255" for in the mid function? is that arbitrary?
Yes, I just made it up. But if your cells go up to Col100 then use 1000.
Another way would be to replace every Col with ,Col and then eliminate the first comma - =SUBSTITUTE(SUBSTITUTE(A1,"Col",",Col"),",","",1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.