Display wrapped text in merged cells

4 views
Skip to first unread message

Melisa Scarpino

unread,
Oct 1, 2003, 7:18:03 AM10/1/03
to
I can't seem to get merged cells to expand and display the
wrapped text. It only seems to work with unmerged cells.
This is a necessity in forms. Can this be done???

Jim Rech

unread,
Oct 1, 2003, 10:47:25 AM10/1/03
to
Merged cells with Wrap Text set do not automatically adjust row heights,
unlike non-merged cells. The only workaround I know of is a macro, for what
it's worth.

--
Jim Rech
Excel MVP

''Simulates row height autofit for a merged cell if the active cell..
'' is merged.
'' has Wrap Text set.
'' includes only 1 row.
''Unlike real autosizing the macro only increases row height
'' (if needed). It does not reduce row height (because another
'' merged cell on the same row may needed a greater height
'' than the active cell).
Sub AutoFitMergedCellRowHeight()
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
If ActiveCell.MergeCells Then
With ActiveCell.MergeArea
If .Rows.Count = 1 And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
ActiveCellWidth = ActiveCell.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth +
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, _
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub


Reply all
Reply to author
Forward
0 new messages