PC Review


Reply
Thread Tools Rate Thread

Autoheight adjustment for merged cells not changing

 
 
bluegrassstateworker
Guest
Posts: n/a
 
      24th Apr 2007
I am missing something... I have the following code below in a module
(Excel-Office2003) obtained from an earlier posting. The merged area
should autoresize when I input information into the merged cell and
hit the enter key but it is not. The code does work fine if I make it
a public function then run it on the cell itself. You can see from
the first line made into a comment my testing method. Other "ByVal"
change testings work fine: I make the change and the code is activated
on that cell when I hit the enter key.
Thanks
**********************************************************

'Sub AutoFitMergedCellRowHeight()
Private Sub Worksheet_Change(ByVal Target As Range)
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
If ActiveCell.MergeCells Then
With ActiveCell.MergeArea
If .Rows.Count = 1 Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
ActiveCellWidth = ActiveCell.ColumnWidth
For Each CurrCell In Selection
MergedCellRgWidth = CurrCell.ColumnWidth +
MergedCellRgWidth
Next
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight,
_
CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with pasting special merged cells to merged cells ritpg Microsoft Excel Programming 3 9th Mar 2010 07:14 PM
Autofit Merged cell Code is changing the format of my merged cells =?Utf-8?B?SkI=?= Microsoft Excel Misc 0 20th Aug 2007 02:12 PM
changing merged cells from code john Microsoft Excel Programming 7 6th Jul 2005 10:24 PM
Row autoheight for merged cells René van Kessel Microsoft Excel Programming 1 12th Apr 2005 02:04 PM
Changing the locked propery of merged cells. =?Utf-8?B?VGhlIFdvbmRlciBUaGluZw==?= Microsoft Excel Programming 1 26th Oct 2004 09:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:50 AM.