Jump to content
JohnOne

Excel right justify columns

Recommended Posts

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

Share this post


Link to post
Share on other sites

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

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-08-19 - Version 1.4.13.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Taks Scheduler (NEW 2019-10-09 - Version 0.9.0.0) - Download - General Help & Support - Wiki

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

Share this post


Link to post
Share on other sites

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


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

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

×
×
  • Create New...