Hello Friends,
I am looking for a solution that automatically expands merged cells for multiple sheets; 1,2
I am working on a project that requires user input on sheet 1 in merged cells;C14:G14. My 1st challenge is to have the merged range expand automatically as the text expands.
Part 2 of the challenge is a have sheet 2 that is a mirror of sheet for the most part
(I am using ='Sheet 1'!C14:G14 to accomplish this) do the same thing...
I have been working with the code below which does what I need in the active cell.
Any help would be appreciated !!
[pre]
[/pre]
I am looking for a solution that automatically expands merged cells for multiple sheets; 1,2
I am working on a project that requires user input on sheet 1 in merged cells;C14:G14. My 1st challenge is to have the merged range expand automatically as the text expands.
Part 2 of the challenge is a have sheet 2 that is a mirror of sheet for the most part
(I am using ='Sheet 1'!C14:G14 to accomplish this) do the same thing...
I have been working with the code below which does what I need in the active cell.
Any help would be appreciated !!
[pre]
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
Application.ScreenUpdating = True
End Sub