The first part looks for a name range
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
Const sRange1 = "Ground"
Dim oCell As Range
If Not Intersect(Target, Range(sRange1)) Is Nothing Then
For Each oCell In Intersect(Target, Range(sRange1))
AFMCRH oCell
Next oCell
End If
End Sub
If target range is selected then this code from a module will run to adjust row height
Code: Select all
Sub AFMCRH(rng As Range)
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
If rng.MergeCells Then
Application.ScreenUpdating = False
With rng.MergeArea
If .Rows.Count = 1 And .WrapText = True Then
Application.ScreenUpdating = False
CurrentRowHeight = .RowHeight
ActiveCellWidth = .Cells(1).ColumnWidth
For Each CurrCell In rng.MergeArea
MergedCellRgWidth = CurrCell.ColumnWidth + MergedCellRgWidth
Next CurrCell
.MergeCells = False
.Cells(1).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(1).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = PossNewRowHeight
End If
End With
Application.ScreenUpdating = True
End If
End Sub
If ActiveCell.Validation.Formula1 Then