Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default I need to add spaces to the beginning of my texts which are numbers

example I have various account numbers as texts from 4 to 7 digits. I
need to make all account numbers 10 digits long with spaces at the
beginning. Another example....
_ _ _ 1234567.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 621
Default I need to add spaces to the beginning of my texts which are numbers

Sub fill_spaces_left()
Dim s As String
Dim cell As Range
For Each cell In Selection
With cell
.NumberFormat = "@"
.HorizontalAlignment = xlRight
s = .Value
If Len(s) < 10 Then
.Value = Space$(10 - Len(s)) & s
End If
End With
Next
End Sub


Gord

On Tue, 24 Apr 2012 10:46:10 -0700 (PDT), Demetria Jones
wrote:

example I have various account numbers as texts from 4 to 7 digits. I
need to make all account numbers 10 digits long with spaces at the
beginning. Another example....
_ _ _ 1234567.

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 remove spaces at the beginning of cells? Munkeeric Excel Discussion (Misc queries) 3 January 5th 10 06:39 PM
Delete Variable spaces at beginning of a range gmunro Excel Programming 4 August 21st 07 02:26 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
How do I eliminate spaces/characters from the beginning of a cell A Waller Excel Worksheet Functions 1 June 29th 05 10:37 PM
Remove Spaces beginning Time entry Damon Longworth Excel Discussion (Misc queries) 10 June 19th 05 04:37 PM


All times are GMT +1. The time now is 05:15 AM.

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

About Us

"It's about Microsoft Excel"