Home » excel » adding text in between a string in excel

adding text in between a string in excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

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?

How to&Answers:

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)