ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I set text alignment in code. (https://www.excelbanter.com/excel-programming/359053-how-do-i-set-text-alignment-code.html)

Patch61

How do I set text alignment in code.
 
The help files for programming in excel are ridiculously atrocious. It's way
too hard to find what you are looking for.

What I want to know is how do I set the alignment (justification) of text in
a cell using vb code?



Jim Cone

How do I set text alignment in code.
 
The "best" Excel help exists in XL 97. It responds much quicker and gives you "mush"
when you enter mush not "soup". I have/use three versions of XL, but use the XL 97
help for all of them. From that help file...

"HorizontalAlignment Property"
Returns or sets the horizontal alignment for the object. Read/write Long

For all objects, this can be one of the following XlHAlign constants:
xlHAlignCenter, xlHAlignDistributed, xlHAlignJustify, xlHAlignLeft, or xlHAlignRight.

In addition, for the Range or Style object, this property can be set to:
xlHAlignCenterAcrossSelection, xlHAlignFill, or xlHAlignGeneral.

This example left aligns the range A1:A5 on Sheet1...
Worksheets("Sheet1").Range("A1:A5").HorizontalAlig nment = xlLeft
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Patch61"
wrote in message
The help files for programming in excel are ridiculously atrocious. It's way
too hard to find what you are looking for.
What I want to know is how do I set the alignment (justification) of text in
a cell using vb code?



Patch61

How do I set text alignment in code.
 
found it:
Worksheets("Sheet1").Range("A1:A5").HorizontalAlig nment = xlLeft

"Patch61" wrote:

The help files for programming in excel are ridiculously atrocious. It's way
too hard to find what you are looking for.

What I want to know is how do I set the alignment (justification) of text in
a cell using vb code?




All times are GMT +1. The time now is 07:28 AM.

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