ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Wrapping Text in Merged Cells - Excel 2002 (https://www.excelbanter.com/excel-discussion-misc-queries/229381-wrapping-text-merged-cells-excel-2002-a.html)

Cornelia

Wrapping Text in Merged Cells - Excel 2002
 
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.


Gord Dibben

Wrapping Text in Merged Cells - Excel 2002
 
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.



Cornelia

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.




Gord Dibben

Wrapping Text in Merged Cells - Excel 2002
 
I would guess the sheet is protected.

Try this version.

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
On Error GoTo endit
ActiveSheet.Unprotect Password:="justme"
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
endit:
ActiveSheet.Protect Password:="justme"
End Sub


Gord

On Mon, 11 May 2009 10:15:02 -0700, Cornelia
wrote:

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.






All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com