Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
David
 
Posts: n/a
Default AutoFitMergedCellRowHeight - Jim Rech

Greetings,
Jim Rech's code works great for this, see:
http://groups.google.com/groups?thre...%40tkmsftngp05

But is it possible to trigger this with an event so that when the selection
is changed FROM the merged cell the code runs for the merged cell (ie would
be equivalent to BeforeSelectionChange)
Many Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Greg Wilson
 
Posts: n/a
Default AutoFitMergedCellRowHeight - Jim Rech

Paste to the worksheet's code module:

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

The above is an adaption of Jim Rech's code from a recent post of mine.

Regards,
Greg

"David" wrote:

Greetings,
Jim Rech's code works great for this, see:
http://groups.google.com/groups?thre...%40tkmsftngp05

But is it possible to trigger this with an event so that when the selection
is changed FROM the merged cell the code runs for the merged cell (ie would
be equivalent to BeforeSelectionChange)
Many Thanks

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
Formulae, conditional formatting & macro security Kevin Lucas Excel Discussion (Misc queries) 7 March 15th 05 01:10 PM
Creating names Ann Shaw Excel Discussion (Misc queries) 14 March 4th 05 10:00 AM
Autofitting a row Josephine Excel Discussion (Misc queries) 2 March 3rd 05 03:37 PM
Vlookup in a userform R D S Excel Discussion (Misc queries) 6 January 26th 05 09:22 PM
Automatic Autofit oranskeer Excel Discussion (Misc queries) 6 January 6th 05 01:33 PM


All times are GMT +1. The time now is 05:04 PM.

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

About Us

"It's about Microsoft Excel"