Solved

cell formatting in excel

Posted on 2014-04-10
3
199 Views
Last Modified: 2014-04-16
hi there

we generate a report form our company file and export this to excel - we would like to have a macro that automatically formatted cells in a particular range so that the text is vertical from top to bottom, and then for the row to be automatically justified.

Is this possible?

The cell range we would like to amend is from $I$3:$FS$3

thanks fo ryour help
0
Comment
Question by:Rossco_milkbar
  • 2
3 Comments
 
LVL 21

Expert Comment

by:Ejgil Hedegaard
ID: 39992953
Something like this

Sub RotateTextRow3()
    With Range("I3:FS3")
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 90
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Rows("3:3").EntireRow.AutoFit
End Sub

Open in new window

0
 

Author Comment

by:Rossco_milkbar
ID: 39992993
Thanks Hgholt - works great, except the display of the cells need to be oriented to the bottom of the cell - currently it is shown at the top of the cell and only show partial text.

Can you make a slight modification??

Thanks!!!!!
0
 
LVL 21

Accepted Solution

by:
Ejgil Hedegaard earned 500 total points
ID: 39994254
Standard is bottom display, but you specified "vertical from top to bottom", that is why I thought it was the intention.
Change xlTop to xlBottom.

Only showing partial text can have more reasons.
Some text fonts, and if Bold, does not always set the correct row height when Autofit is used, or WrapText = False should be True.
Sometimes to Autofit (=double click between 2 row numbers) need to have the rows higher than needed before used, don't know why.

Try doing the setting manually, and record a macro when doing it, it will look like the code above.
Just mark one cell, then copy the code between "With Selection" and "End With" (all the lines starting with a dot) and insert it between "With Range("I3:FS3")" and "End With", replacing all the dot lines.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the hope of saving someone else's sanity... About a year ago we bought a Cisco 1921 router with two ADSL/VDSL EHWIC cards to load balance local network traffic over the two broadband lines we have, but we couldn't get the routing to work consi…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Viewers will learn various types of data validation for different data types in Excel 2013.
Viewers will learn a basic relationship technique in Power Pivot for Excel 2013.

920 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now