I have a column of text strings of varying lengths from 1 to 512 chars. I would like to insert a comma every 79 chars. I found a function that inserts a comma every 2 chars so I thought it would be easy to convert it to every 79 chars but I can't figure it out. I keep ending up with a mess. Can anyone help me fix this?
Code
Function InsertComma(Text As String) As String
If Len(Text) < 3 Then InsertComma = Text
Dim i As Integer
Dim T As String
T = Left(Text, 2)
For i = 3 To Len(Text) Step 2
T = T & "," & Mid(Text, i, 2)
Next i
InsertComma = T
End Function
found here: http://www.mrexcel.com/archive/VBA/16676.html
This was my failed attempt at modifying it: