Bonjour à tous,
Lorsque vous fusionnez des cellules pour pouvoir ensuite faire un alignement à gauche, il devient impossible d'ajuster correctement la hauteur de la ligne contenant ces cellules fusionnées (habituellement un double clic entre les deux lignes).
Voici un exemple.
Pour réussir à aboutir à ce résultat :

Voici la macro de 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
A bientôt.
Gaetan
Bonjour,
Je viens de tester le code sur l'un de mes fichiers mais ça ne donne rien. Y aurait-il des conditions pour exécuter ce code? La feuille sur laquelle j'ai effectué le test commence à la ligne 6.
Merci beaucoup.
Cordialement,
Bonjour,
Pourriez vous m'envoyer le fichier pour que je regarde où se trouve le bug?
Merci
Gaetan
Parfait , Nickel et TOP!
Merci
Macro plus que Ok, Merci