PC Review


Reply
Thread Tools Rate Thread

Characters same length in column

 
 
ktuprah
Guest
Posts: n/a
 
      7th Dec 2009
Thank You so much for your advice. The problem is the data comes into excel
from a different program and then has to be exported to notepad. So lets
say the account# column is supposed to have 10 characters and a cell only
has 7. Then when it goes to notepad it would have original 7 characters and
3 spaces. Would you be able to look at the following code and give some
advice(the output has been left as comments as they are in theory)?



Private Sub Worksheet_Change(ByVal Target As Range)

Const MaxLen As Long = 10

If Target.Column = 4 And Len(Target.Value) < MaxLen Then

MsgBox "Entry too short"

Application.EnableEvents = False

dif = MaxLen - Len(Target.Value)

result = Rep(" ", difference) & Target.Value



Dim Check, Counter

Check = True: Counter = 0



Do While Counter < dif

Counter = Counter + 1

Spaces = spaces & " "

Loop



Spaces2='Target.Value = Replace(Target.Value, 1 - difference, difference, "
")



'Target.Value = CONCATENATE(REPT(" ",difference),Target.Value)

'Target.Value = spaces & Target.Value

'Target.Value = spaces2 & Target.Value



Application.EnableEvents = True

End Sub


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Specify certain length(characters) when defining a column ktuprah Microsoft Excel Programming 3 7th Dec 2009 06:08 PM
Specify certain length(characters) when defining a column ktuprah Microsoft Excel Programming 0 7th Dec 2009 05:32 PM
Specify certain length(characters) when defining a column ktuprah Microsoft Excel Programming 0 7th Dec 2009 04:49 PM
Smart or stupid? Tying textbox length to database column length Dan Manes Microsoft ASP .NET 1 23rd Apr 2006 11:57 PM
Name Box - length of characters displayed =?Utf-8?B?SldH?= Microsoft Excel Misc 3 28th Aug 2004 09:48 PM


Features
 

Advertising
 

Newsgroups
 


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