JohnOne

Excel right justify columns

5 posts in this topic

#1 ·  Posted (edited)

I have a couple of columns where the data in them is left justified.

The column to it's left is right justified and it looks crappy.

How to get those columns to right justify.

I tried 2 ways below which were unsuccessful.

$oAppl.ActiveSheet.Columns("G:H").HorizontalAlignment = $oAppl.HorizontalAlignment.xlRight

$oAppl.ActiveSheet.Columns("G:H").HorizontalAlignment.xlRight
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

When you are talking about columns, rows or cells the starting point is the Ranges object in MSDN (Excel 2010).

The list of enumerations starts here (Excel 2010).

In your case use:

Global Const $xlRight = -4152
$oAppl.ActiveSheet.Columns("G:H").HorizontalAlignment = $xlRight
Edited by water
1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Cheers. I was searching for something like that on msdn but could not find it.

Got my answer ... http://stackoverflow.com/questions/6952084/excel-cell-alignments-numerical-values-for-e-g-xlleft-xlright-or-xlcenter


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

you cant just whip out -4152 in front of muggles.

1 person likes this

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now