Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2006

Tip: Looking for answers? Try searching our database.

Merged Cells and Row Height

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gwinder@yamaha.com - 16 Dec 2006 12:32 GMT
I know this is an old topic and I have tried many things including Jim
Rech's code which everyone tells me should work, but for some reason
doesn't for me.

My cell range is A42:AA142.  In the following code from Jim, where do I
reference the cell range or should the code apply to the worksheet so
there is no need to reference the cells?  If that's the case, is there
something I need to do when I have pasted this code?

Thanks,

Gary

Sub AutoFitMergedCellRowHeight()
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 And .WrapText = True 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
Dave Peterson - 16 Dec 2006 15:08 GMT
Please don't start new threads when you have an active thread elsewhere.

> I know this is an old topic and I have tried many things including Jim
> Rech's code which everyone tells me should work, but for some reason
[quoted text clipped - 35 lines]
> End If
> End Sub

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.