View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Cornelia Cornelia is offline
external usenet poster
 
Posts: 18
Default Wrapping Text in Merged Cells - Excel 2002

Hi Gord,

I cut and pasted the macro below and I am getting a error on the ----
ma.MergeCells = False ---- line, any suggestions?


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" wrote:

Wrap text text works fine in merged cells.

However.............autofitting of row height does not work.

See google search thread for code by Greg Wilson. Watch out for word wrap
in the URL which is all one line.

http://groups.google.com/group/micro...1c160cbeb27874

If this code is one of the macros you tried, please post back and explain
what is or is not happening.


Gord Dibben MS Excel MVP

On Thu, 30 Apr 2009 11:34:25 -0700, Cornelia
wrote:

I have merged cells which have condiational formatting applies, the wrap text
is checked and the text will not wrap.

I have tried a few of the macros which were mentioned in other questions
with no success.

Anyone have any suggestions.