Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
RowHeight automatically change when user does ALT+ENTER for linefe
Merged cells won't autofit for row height.
here is some code written by Jim Rech which sizes the rowheight for a merged cell. Perhaps you can incorporate a similar approach in your code. 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 -- Regards, Tom Ogilvy "GaryZ" wrote in message ... Hi, I have a VFP program that generates a spreadsheet. In the generated spreadsheet, I have a cell merged across columns A through D used for a multiline comment. For the cell, I have WordWrap = True. However, when the user puts a linefeed into the comment via ALT+ENTER, the RowHeight does not adjust and only one line of the comment is visible. Is there any way, while generating the spreadsheet, to mark the cell with automatically adjustable rowheight? Here is the source for the cell definition. m_row = m_row + 1 strrow = ALLT(STR(m_row)) .Range("A"+strrow+":D"+strrow).mergecells = True With .Range("A"+strrow) .WrapText = True .HorizontalAlignment = xlLeft EndWith |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Is RowHeight=0 the same as Hidden | Excel Discussion (Misc queries) | |||
In Excel why does the date I enter automatically change by 1 day? | Excel Worksheet Functions | |||
In Excel why does the date I enter automatically change by 1 day? | Excel Worksheet Functions | |||
Automatically changing the rowheight | Excel Programming | |||
autofit rowheight after auto change line | Excel Programming |