merged cells and wrap text

  • Thread starter Thread starter Guest
  • Start date Start date
Well it perhaps looks that way but in my sheets the cell does wrap. However
you may need to increase the cell height by hand. What I do notice in my
sheets that if you try to double click the rowheight to automatically set the
height it will go to the default row height.

Good luck
 
Thanks
--
Richard


RudyHuls said:
Well it perhaps looks that way but in my sheets the cell does wrap. However
you may need to increase the cell height by hand. What I do notice in my
sheets that if you try to double click the rowheight to automatically set the
height it will go to the default row height.

Good luck
 
Long audible sigh here.................

One more victim of "merged cells".

Wrap Text works fine on merged cells, but Autofit does not work.

You need VBA event code to do that.

Here is code from Greg Wilson.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim NewRwHt As Single
Dim cWdth As Single, MrgeWdth As Single
Dim c As Range, cc As Range
Dim ma As Range

With Target
If .MergeCells And .WrapText Then
Set c = Target.Cells(1, 1)
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
Application.ScreenUpdating = False
ma.MergeCells = False
c.ColumnWidth = MrgeWdth
c.EntireRow.AutoFit
NewRwHt = c.RowHeight
c.ColumnWidth = cWdth
ma.MergeCells = True
ma.RowHeight = NewRwHt
cWdth = 0: MrgeWdth = 0
Application.ScreenUpdating = True
End If
End With
End Sub

This is event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into that sheet module.


Gord Dibben MS Excel MVP
 
Back
Top