Solved

cell formatting in excel

Posted on 2014-04-10
3
204 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 22

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 22

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Viewers will learn a basic data manipulation technique of unpivoting data in Power Query for Excel 2013 and the importance of using good data. Start with data in a poor structure: Create a table on your data: Unpivot columns: Rename columns: …
Video by: Zack
Viewers will learn the basics of using Excel Tables, the benefits found with them, and some pitfalls.

756 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