Solved

VBA to set Cell Orientation

Posted on 2014-02-07
3
1,162 Views
Last Modified: 2014-02-07
I am trying to set the cell orientation of the first row of my worksheet to xlUpward but I cannot get it to work, can anyone help me accomplish this?

I've tried about 30 things and nothing is working. This is what I currently have in my code.

"... all of the usual Dim objects to open the spreadsheet etc...then"

    oWsh.Activate
    With oWsh
        .Range("1:1").Font.Bold = True <--this works
        .Range("1:1").Select
            With Selection
                .Orientation = xlUpward <--it breaks here
            End With
    End With
0
Comment
Question by:boukaka
3 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39842832
if you add to your references the Excel object library, that should work.

if you are using Late Binding, you have declare the value of  xlUpward

Const xlUpward = -4171

or just use
 .Orientation =-4171
0
 

Author Comment

by:boukaka
ID: 39842868
YOU ARE A LIFESAVER!!! Thank you so much.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39842869
Try:
oWsh.Activate
    With oWsh
        .Range("1:1").Font.Bold = True <--this works
        .Range("1:1").Orientation = xlUpward
    End With
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question