Automatically changing the rowheight
Perhaps you can adapt this code posted previously by Jim Rech, to achieve
what you want:
Jim Rech
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
"Ajit" wrote in message
...
I have a cell(merged)-(lets say cell-1) which is being fed from the input
from the form. In the excel sheet i have around 20 cells (some of them
merged) which references to the cell-1. To all the 20 cells i have =cell-1
formula written.
Is there a way that if i increase or decrease the rowheight of cell-1, all
the rowheights change accordingly.
Note : I tried autofit but that doesn't work fine with merged cells.
Thanks
|