Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I seem to hit a deadend in the following topic, but came across another
idea. http://groups.google.com/group/micro...9 a0b49426a28 What I am trying to do is make a merged cell automatically adjust the row height if the text is longer than the cell width. The merged cells are all formatted to wrap text. Here is what the code looks like: Private Sub Worksheet_SelectionChange(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 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 The problem with this code is that it only works when you first select the cell. What we have to do is type the text, navigate away and reselect the cell. I want it to run it's routine when the enter key is pressed or you navigate away from the active cell. How can this code be changed to accomplish this? Another option would be to have it continuously scan a range or column. Above row 12, the cells are not merged, so I don't know if this would be a problem. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to enable auto height with merged cells? | Excel Worksheet Functions | |||
Auto Row Height in Merged Cells with pre exisiting text | Excel Programming | |||
Auto row height for merged cells | Excel Programming | |||
Solution To Auto Height For Merged Cells | Excel Programming | |||
Auto Row Height for Merged Cells | Excel Programming |