Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Using macro record mode, I created a macro that inserts a row, sets
the format alignment to Right with Wrap Text selected, then inserted titles in each cell, some which include chr(10) to create multi-line titles. The VBA looks like this: Rows("1:1").Select : Selection.Insert Shift:=xlDown With Selection .HorizontalAlignment = xlRight : .VerticalAlignment = xlBottom .WrapText = True : .Orientation = 0 : .AddIndent = False .IndentLevel = 0 : .ShrinkToFit = False : .ReadingOrder = xlContext .MergeCells = False End With Range("A1").Select : ActiveCell.FormulaR1C1 = "Year" Range("B1").Select : ActiveCell.FormulaR1C1 = "Your" & Chr(10) & "Age" [... etc ...] Since some of the original columns are not wide enough, the text wraps within the too-narrow limits of the cell. I tried to correct that by manually highlighting all columns, then clicking on Format Column Autofit Selection. That generated the following VBA code: Columns("A:N").Select : Selection.Columns.AutoFit But that failed to widen the columns to accomodate the text up to the line break [chr(10)]. I can widen the columns to accomodate the text up to the line break, both manually and in VBA? (Actually, if you tell me how to do it manually, I can learn the VBA using macro record mode.) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
autofit row text (wrapped) without changing column width? | Excel Discussion (Misc queries) | |||
Autofit in cells with multiple lines of wrapped text. | Excel Programming | |||
Autofit Column Headers with wrapped text (Not a merged cell issue) | Excel Programming | |||
Autofit merged cells with wrapped text | Excel Programming | |||
Autofit merged cells with wrapped text | Excel Programming |