Display wrapped text in merged cells

Skip to first unread message

Melisa Scarpino

Oct 1, 2003, 7:18:03 AM10/1/03
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

Oct 1, 2003, 10:47:25 AM10/1/03
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 +
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
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
0 new messages