Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() I ahve the following code assigned to a worksheet. It simply will not work and I cannot figure out why. What it does: This code expands merged cells where the text wraps. I go it to work with a different event but it will not work with this set up. I would like it to run when a user exits any cell. Any ideas are appreciated. 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 Application.EnableEvents = False 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 Application.EnableEvents = True End Sub Thanks Dan -- retseort ------------------------------------------------------------------------ retseort's Profile: http://www.excelforum.com/member.php...o&userid=24690 View this thread: http://www.excelforum.com/showthread...hreadid=487788 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
need help creating a Worksheet_Change code | Excel Worksheet Functions | |||
Code WAY too slow... (worksheet_change event) | Excel Programming | |||
worksheet_change vs. calculate, and worksheet_change not running | Excel Programming | |||
worksheet_change vs. calculate, and worksheet_change not running | Excel Programming |