Hi,

I assume by the leading zeros that the cell is formatted as text.

Try this code, which assumes that your data is in cell E2

 

Sub InsertComma()
A = 8
B = Len(Range("E2"))
Do Until A > B
B = Len(Range("E2"))
C = Left(Range("E2"), A)
D = Right(Range("E2"), (B - A))
Range("E2") = C & "," & D
A = A + 9
Loop
End Sub

 

To apply this to lots of data, you will need to include it in a loop to go thru 
all cells in your range.

 

Regards - Dave.
 
> Date: Wed, 12 May 2010 09:44:41 -0700
> Subject: $$Excel-Macros$$ Insert comma every 8 characters with random length 
> cells
> From: jorgenso...@gmail.com
> To: excel-macros@googlegroups.com
> 
> I need a formula that inserts a comma every 8 characters in a cell.
> The cell length could be from 8 to over 3000 characters. In this case,
> the LEFT, MID, and RIGHT does not work because of random length cells
> and the amount of characters. Any help would be appreciated.
> 
> Example:
> 
> 000020480000204900002050
> 
> would be
> 
> 00002048,00002049,00002050, etc.
> 
> -- 
> ----------------------------------------------------------------------------------
> Some important links for excel users:
> 1. Follow us on TWITTER for tips tricks and links : 
> http://twitter.com/exceldailytip
> 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
> 3. Excel tutorials at http://www.excel-macros.blogspot.com
> 4. Learn VBA Macros at http://www.quickvba.blogspot.com
> 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
> 
> To post to this group, send email to excel-macros@googlegroups.com
> 
> <><><><><><><><><><><><><><><><><><><><><><>
> HELP US GROW !!
> 
> We reach over 6,800 subscribers worldwide and receive many nice notes about 
> the learning and support from the group.Let friends and co-workers know they 
> can subscribe to group at 
> http://groups.google.com/group/excel-macros/subscribe
                                          
_________________________________________________________________
Need a new place to live? Find it on Domain.com.au
http://clk.atdmt.com/NMN/go/157631292/direct/01/

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to