Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default Insert Spaces

I need to know how to insert spaces at given positions in a string.
There are 27 characters (positions) and it would go as follows;

111223333334445566666666666

Changed to;
111 22 333333 444 55

Dim tmpName2 As String
tmpName2 = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 11)

The first statements removes the last 11 characters and leaves
1112233333344455

What I need is the syntax to insert the spaces in the name at position 4, 7
14 and 18.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Insert Spaces

sVal = "111223333334445566666666666"
ary = Array(4, 7, 14, 18)

For i = LBound(ary) To UBound(ary)
sVal = Left(sVal, ary(i) - 1) & " " & Right(sVal, Len(sVal) - ary(i)
+ 1)
Next i

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ronbo" wrote in message
...
I need to know how to insert spaces at given positions in a string.
There are 27 characters (positions) and it would go as follows;

111223333334445566666666666

Changed to;
111 22 333333 444 55

Dim tmpName2 As String
tmpName2 = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name) - 11)

The first statements removes the last 11 characters and leaves
1112233333344455

What I need is the syntax to insert the spaces in the name at position 4,

7
14 and 18.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I insert spaces between characters mayoyo Excel Discussion (Misc queries) 1 October 3rd 07 11:46 AM
Insert spaces in text string in Excel GenaroJP Excel Discussion (Misc queries) 1 October 16th 06 06:06 PM
How can I insert 2 spaces at the beginning of each of 1300 cells? spaceless in Dallas Excel Discussion (Misc queries) 3 October 13th 06 05:50 PM
Insert spaces in String of Numbers Marianne Excel Worksheet Functions 1 August 25th 06 06:32 PM
How do I take two columns of sequential numbers and insert spaces cmrdjr Excel Discussion (Misc queries) 5 December 2nd 04 10:35 PM


All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"