LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default auto expand row hieght of merged cells

I found a similar issue worked on by Greg for Jamie just last week, but I can
not get this to work for my situation;

I am working on an excel 2002 spread sheet that is use as a form with
protected cells, and merged cells. The 4 merged cells need to be able to
expand the height when they enter more then what fits on 2 lines. There are
more then 12 such merged cells in this spread sheet and this is the code I
was trying to use.

Modified from what Greg posted last week;
Private Sub Worksheet_SelectionChange(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
Dim Protected As Boolean
Dim OldRng As Range
Const Pwd As String = "monkey"

Protected = False
Set c = Cells(Active.Range) <<<< modified this line
'Set c = Cells(22, 1)
If OldRng Is Nothing Then Set OldRng = c
If Not Intersect(OldRng, c) Is Nothing Then
Application.ScreenUpdating = False
If Me.ProtectContents Then
Protected = True
Me.Unprotect Pwd
End If
cWdth = c.ColumnWidth
Set ma = c.MergeArea
For Each cc In ma.Cells
MrgeWdth = MrgeWdth + cc.ColumnWidth
Next
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
If Protected Then Me.Protect Pwd
Application.ScreenUpdating = True
End If
Set OldRng = Target
End Sub

 
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
Excel: How do I auto expand Cells to show all the wrapped text? DonnaTypes01 Excel Worksheet Functions 5 November 25th 08 04:38 PM
How can I automatically expand merged cells to fit text in excel Michelle Bance Excel Discussion (Misc queries) 1 February 19th 07 02:19 PM
How do I auto fit when the cells are merged together? Christa Excel Worksheet Functions 1 November 1st 05 05:35 PM
Auto Row Height for Merged Cells Jamie Excel Programming 13 July 1st 05 12:55 AM
Auto fit merged cells Anson Excel Discussion (Misc queries) 1 December 20th 04 09:09 PM


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

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"