Solved

cell formatting in excel

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel: Counting Number of Orders / Grouping by Months 13 74
Excel - Split text at '(' and ')' characters 3 83
MS Excel shared file syncing 8 75
kendo spreadsheet data return 15 94
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
: Microsoft Office Collaborate for free and online versions of Microsoft  Word, Excel, Powerpoint, OneNote, Onedrive , Email, Calendar etc. In short we can say that Microsoft office is a suite of servers, applications and services developed by  Micr…
Viewers will learn the basics of using filtering and sorting in Excel 2013.
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: …

829 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