Bonsoir, couettecouette et Nad-Dan,
En reprenant le code fourni précédemment, et en le modifiant quelque peu pour parcourir une zone à déterminer
tu peux essayer ceci :
Sub AutoFitMergedCellRowHeight()
Dim CurrentRowHeight As Single, MergedCellRgWidth As Single
Dim CurrCell As Range, Cel As Range
Dim ActiveCellWidth As Single, PossNewRowHeight As Single
For Each Cel In Range("A1:A5") ' <--- Zone à déterminer
If Cel.MergeCells Then
Cel.Select
MergedCellRgWidth = 0: PossNewRowHeight = 0
With ActiveCell.MergeArea
.WrapText = True 'enclenche le renvoi à la ligne automatique (modif fs)
If .Rows.Count = 1 Then '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(Cel.Row, Cel.Column).ColumnWidth = MergedCellRgWidth
.EntireRow.AutoFit
PossNewRowHeight = .RowHeight
.Cells(Cel.Row, Cel.Column).ColumnWidth = ActiveCellWidth
.MergeCells = True
.RowHeight = IIf(CurrentRowHeight > PossNewRowHeight, CurrentRowHeight, PossNewRowHeight)
End If
End With
End If
Next Cel
End Sub