View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Melanie Melanie is offline
external usenet poster
 
Posts: 78
Default Can't Wrap text in the Merge Cells

I am having the same issue, please could you explain how to use the VBA code
below.

Thanks

Melanie

"Gord Dibben" wrote:

Winnie

Wrap text works fine on merged cells.

Your problem is...............Rows with Merged cells will not Autofit.

You need VBA 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


Gord Dibben MS Excel MVP

On Wed, 30 Aug 2006 22:18:01 -0700, Winnie
wrote:

When I choose Merge cells and Wrap text function in the Text control.

the Wrap text function not working in the merger cells?

Please help


Gord Dibben MS Excel MVP