ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to insert a space (https://www.excelbanter.com/excel-programming/356921-macro-insert-space.html)

Lame Dame via OfficeKB.com

Macro to insert a space
 
Hi

I need a macro to insert a space every 4 characters e.g.

It will change the contents of :

CY11A01

To

CY11 A01

Any ideas??

--
Message posted via http://www.officekb.com

Gary Keramidas

Macro to insert a space
 
do you only need to add a space after the first 4 characters?

Sub test2()
slen = Len(Range("a1"))

Range("b1").Value = Left(Range("a1"), 4) & " " & Right(Range("a1"), slen - 4)

End Sub

--


Gary


"Lame Dame via OfficeKB.com" <u15117@uwe wrote in message
news:5db1018f45b69@uwe...
Hi

I need a macro to insert a space every 4 characters e.g.

It will change the contents of :

CY11A01

To

CY11 A01

Any ideas??

--
Message posted via http://www.officekb.com




Lame Dame via OfficeKB.com

Macro to insert a space
 
thanks

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200603/1


All times are GMT +1. The time now is 02:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com