Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would like to fix the length of column B to 10 characters. if actual vale
is less than 10 characters, I would like to pad rightmost characters with spaces. Any help would be appreciated. Prema |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this small event macro:
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Range("B:B"), Target) Is Nothing Then t = Target.Value n = Len(t) If n 10 Then t = Right(t, 10) Application.EnableEvents = False Target.Value = t Application.EnableEvents = True Exit Sub End If If n < 10 Then t = t & Application.Rept(" ", 10 - n) Application.EnableEvents = False Target.Value = t Application.EnableEvents = True Exit Sub End If End If End Sub If the input is less than 10 characters, the padding is applied. iIf the input is greater than 10 characters, the result is truncated. -- Gary''s Student - gsnu200719 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you.
Prema "Gary''s Student" wrote: Try this small event macro: Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Range("B:B"), Target) Is Nothing Then t = Target.Value n = Len(t) If n 10 Then t = Right(t, 10) Application.EnableEvents = False Target.Value = t Application.EnableEvents = True Exit Sub End If If n < 10 Then t = t & Application.Rept(" ", 10 - n) Application.EnableEvents = False Target.Value = t Application.EnableEvents = True Exit Sub End If End If End Sub If the input is less than 10 characters, the padding is applied. iIf the input is greater than 10 characters, the result is truncated. -- Gary''s Student - gsnu200719 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text to column fixed length | Excel Discussion (Misc queries) | |||
I'd like to have the X-axis a fixed length. | Charts and Charting in Excel | |||
create fixed length cells & rows in excel as space delimited .prn | Excel Discussion (Misc queries) | |||
fixed length file | Excel Discussion (Misc queries) | |||
Save as FIXED LENGTH | Excel Programming |