How do I insert a character in middle of cell data?

DMAinCA

New Member
Joined
Apr 10, 2013
Messages
4
I need to insert a comma into a column of cells. What is the best way to do this?

Example:
Currently: 1296 Smitty's Snail Shop
Needs to be: 1296, Smitty's Snail Shop

Although the comma needs to be inserted in the same place in each cell (after the four digit #) not all of the cells contain the same character length, i.e. the next one says, "1298 Suzanne's Serpent Store."

I've found many ways of doing this when all of the cells have the same character length, but have been unable to find anything that applies to varied lengths. :eek:

Thanks in advance for any help!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
This is Scott's idea, but set up in macro form in order to change the original text within their cells rather than output the change to a new column...
Code:
Sub InsertCommasAtPosition5()
  Dim Addr As String
  Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
  Range(Addr) = Evaluate(Replace("IF(LEN(@),REPLACE(@,5,0,"",""),"""")", "@", Addr))
End Sub
 
Upvote 0
I tried this formula before posting to the forum and it didn't work. I see now that my original Excel spreadsheet may be corrupt as I copy and pasted my original data into a completely new workbook, tried the formula again there and it worked fine. Thanks so much!
 
Upvote 0
=replace(a1,5,0,",")


I tried this formula before posting to the forum and it didn't work. I see now that my original Excel spreadsheet may be corrupt as I copy and pasted my original data into a completely new workbook, tried the formula again there and it worked fine. Thanks so much!​
 
Upvote 0
This is Scott's idea, but set up in macro form in order to change the original text within their cells rather than output the change to a new column...
Code:
Sub InsertCommasAtPosition5()
  Dim Addr As String
  Addr = "A1:A" & Cells(Rows.Count, "A").End(xlUp).Row
  Range(Addr) = Evaluate(Replace("IF(LEN(@),REPLACE(@,5,0,"",""),"""")", "@", Addr))
End Sub


Thank you!
 
Upvote 0

Forum statistics

Threads
1,196,188
Messages
6,013,927
Members
441,796
Latest member
kmag

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top