ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Format text - Event (https://www.excelbanter.com/excel-programming/346565-format-text-event.html)

al007

Format text - Event
 
Looking for a worksheet event code which would format text entry in
cells as follows:

..HorizontalAlignment = xlJustify
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False

Can anybody help

Thxs


Leith Ross[_334_]

Format text - Event
 

Hello al007,

You can create a new Style for the Workbook. Your Style then become
the default for all worksheets, eliminating redundant worksheet even
code.

Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=48808


al007

Format text - Event
 
I'm already using a style with cells formatted as custom numbers &
can't have both in text.
That's why I was thinking about a worksheet event - can u help pls
thxs


Patrick Molloy[_2_]

Format text - Event
 
you could use the worksheet's CHANGE event. This is fired when teh ENTER key
is pressed. The 'Target' variable is teh cell or cells changed. Since I want
to avoid formatting numbers, I want to test for them, The Target.Range("A1")
ensures that I test the first cell if more than one cell was enterrd.

Paste this code into the worksheet's code page. Tip: a quick way to the code
page is to select it from the pop-up menu that appears when you RIGHT-Click
thesheet tab...

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Not IsNumeric(Target.Range("A1")) Then

With Target

.HorizontalAlignment = xlJustify
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False

End With

End If

End Sub


"al007" wrote:

Looking for a worksheet event code which would format text entry in
cells as follows:

..HorizontalAlignment = xlJustify
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False

Can anybody help

Thxs



al007

Format text - Event
 
Thxs very much !!!!!!!!!!



All times are GMT +1. The time now is 06:45 AM.

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