Ilino
XLDnaute Barbatruc
Bonjour FOrum
ci dessous le code de retour chariot elaboré par JOB en 19/05/2013 a 11h02( je tien a le remerci) et adapter par ILINIO;
Mon souci est : pourquoi il est tres lent quand j'efface les données des cellule fusionnées ( rouge)😕
grazie
ci dessous le code de retour chariot elaboré par JOB en 19/05/2013 a 11h02( je tien a le remerci) et adapter par ILINIO;
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim t As Range
Set t = Intersect(Target, [A4:AG4])
If Not t Is Nothing Then Ajustement t, [A:AG], [A:AG], xlCenter
Set t = Intersect(Target, [B21:AG30])
If Not t Is Nothing Then Ajustement t, [B:AG], [B:AG], xlGeneral
End Sub
Sub Ajustement(t As Range, plage1 As Range, plage2 As Range, align)
Dim r1 As Range, r2 As Range, h As Double
Application.ScreenUpdating = False
For Each t In t ' si plusieurs cellules sont modifiées
Set r1 = Intersect(t.EntireRow, plage1)
Set r2 = Intersect(t.EntireRow, plage2)
Union(r1, r2).UnMerge 'défusionne
r1.HorizontalAlignment = xlCenterAcrossSelection
r2.HorizontalAlignment = xlCenterAcrossSelection
r1.WrapText = True: r2.WrapText = True 'renvoi à la ligne
r1.Rows.AutoFit 'ajustement automatiquement
h = r1.Rows.Height 'mémorise la hauteur
r1.Merge: r2.Merge 'refusionne
Union(r1, r2).HorizontalAlignment = align
If h < 409 Then r1.RowHeight = h 'hauteur de ligne
Next
End Sub
grazie