ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cell justifcation (https://www.excelbanter.com/excel-programming/417312-cell-justifcation.html)

[email protected]

Cell justifcation
 
Below is a snippet of code which puts a : in a number in the cell and
it works great. My problem is that when it does this it changes the
cell justification from Centered to Left justifed. Any way around
this?

If Target.Count=1 And Not Application.Intersect(_
Me.Range("E3:G87"), Target) Is Nothing Then
Application.EnableEvents=False
If IsNumeric(Target.Value) And InStr(Target.Value, ":")=0_
And Len(Target.Value) <5 Then
Target.Value=Format$(Target.Value, "00\:00")

OssieMac

Cell justifcation
 
I am surprised that it changes the justification but to overcome it just add
the following line of code and reset the justification.

Target.HorizontalAlignment = xlCenter

--
Regards,

OssieMac


" wrote:

Below is a snippet of code which puts a : in a number in the cell and
it works great. My problem is that when it does this it changes the
cell justification from Centered to Left justifed. Any way around
this?

If Target.Count=1 And Not Application.Intersect(_
Me.Range("E3:G87"), Target) Is Nothing Then
Application.EnableEvents=False
If IsNumeric(Target.Value) And InStr(Target.Value, ":")=0_
And Len(Target.Value) <5 Then
Target.Value=Format$(Target.Value, "00\:00")



All times are GMT +1. The time now is 04:22 AM.

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