Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Row autoheight for merged cells
Hello,
In Excel I have merged cells to one cell. Now I can't let Excel automatically set the height of the row. The merged cell contains multiple lines (#10). When a row does not contain any merged cells then this works fine. From Delphi I tried following without succes: Excel.Rows[2].EntireRow.AutoFit; Any ideas? Thanks. René |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Row autoheight for merged cells
Rene,
You need to use a macro - see below, written by Jim Rech. Select the cell and run the sub. HTH, Bernie MS Excel MVP 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 .Cells(1).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 "René van Kessel" wrote in message ... Hello, In Excel I have merged cells to one cell. Now I can't let Excel automatically set the height of the row. The merged cell contains multiple lines (#10). When a row does not contain any merged cells then this works fine. From Delphi I tried following without succes: Excel.Rows[2].EntireRow.AutoFit; Any ideas? Thanks. René |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy paste non merged to merged cells | Excel Worksheet Functions | |||
How can I sort an Excel Doc containing merged & non-merged cells? | Excel Discussion (Misc queries) | |||
Autofit Merged cell Code is changing the format of my merged cells | Excel Discussion (Misc queries) | |||
how do i link merged cells to a merged cell in another worksheet. | Excel Worksheet Functions | |||
Sorting merged cellsHow do I sort merged cells not identically siz | Excel Worksheet Functions |