Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VBA to set Cell Orientation

Posted on 2014-02-07
3
Medium Priority
?
1,325 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 2000 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 31

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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
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.

877 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