Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Wrap Text code with merge cells

OK this is the code I have form my previous question he
It works great BUT has one problem. When it does its job and expends the row
to fit the text in one cell, then when I go to the next cell and type
something smaller it overwrights the first cell also. How can I fix this

CODE

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

ActiveSheet.Unprotect Password:="eli"
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

Range("B31:O98").Locked = False

With ActiveSheet
.Protect Password:="eli"
.EnableSelection = xlUnlockedCells
End With
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wrap Text with merge cells code Damian Excel Discussion (Misc queries) 0 August 25th 09 05:13 PM
text outside merge cells despite clicking wrap text chedd via OfficeKB.com Excel Worksheet Functions 5 July 17th 08 09:01 PM
Can't Wrap text in the Merge Cells Winnie Excel Discussion (Misc queries) 13 November 14th 06 07:42 PM
Wrap text, Merge cells ufo_pilot Excel Discussion (Misc queries) 2 August 18th 05 02:16 AM
can wrap text and merge be used together? Elizabeth Excel Discussion (Misc queries) 4 March 15th 05 06:41 PM


All times are GMT +1. The time now is 05:40 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"