Question:

Les cellules fusionnées n’ont pas la bonne hauteur après un saut de ligne. Comment puis-je corriger cela?

Réponse:

Insérez le code suivant dans le module standard.

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