Solved

cell formatting in excel

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
Video by: Zack
Viewers will learn about using Excel in a browser with Excel Online.
Video by: Zack
Viewers will learn about various customizable options in Excel 2013.

743 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

12 Experts available now in Live!

Get 1:1 Help Now