Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Cette macro ne bloque pas mais ne joue pas son rôle

un internaute

XLDnaute Impliqué
Bonjour le forum
Voici la macro ci-dessous

Option Explicit
Sub Tri()
Dim J As Long, LastRow As Long

Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row

Range("A3:E" & LastRow).Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlNo, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Range("F3:J" & LastRow).Sort Key1:=Range("F3"), Order1:=xlAscending, Header:=xlNo, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal


With Rows("3:" & LastRow)
.RowHeight = 50
.AutoFit
End With

For J = 3 To LastRow
If Rows(J).RowHeight <= 18 Then Rows(J).RowHeight = 20
Next J
Application.Goto Range("A1"), Scroll:=True
Application.EnableEvents = True
End Sub

Lorsque je tape un chiffre colonne C ça affiche la date en colonne A
Lorsque je tape un chiffre colonne G ça affiche la date en colonne F
Lorsque je tape un chiffre colonne C et que je modifie la date colonne A pour la mettre à une date antérieure à aujourd'hui par exemple ça fonctionne.
Lorsque je tape un chiffre colonne G et que je modifie la date colonne F pour la mettre à une date antérieure à aujourd'hui par exemple ça ne fonctionne pas.
Je ne vois pas où ça bloque.
Quelqu'un aurait-il une idée?
Merci d'avance
 

un internaute

XLDnaute Impliqué
Bonsoir le forum,
Toutes mes excuses
Je n'avais pas dit que A et F n'était pas toujours sur la même ligne.
Quel CON

Nouvelle macro:

Option Explicit
Sub Tri()
Dim J As Long, LastRow As Long

Application.ScreenUpdating = False
'LastRow = Range("A" & Rows.Count).End(xlUp).Row 'ligne en commentaires
LastRow = Application.Max(Range("A" & Rows.Count).End(xlUp).Row, Range("F" & Rows.Count).End(xlUp).Row)

Range("A3:E" & LastRow).Sort Key1:=Range("A3"), Order1:=xlAscending, Header:=xlNo, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
Range("G3:K" & LastRow).Sort Key1:=Range("G3"), Order1:=xlAscending, Header:=xlNo, _
MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal


With Rows("3:" & LastRow)
.RowHeight = 50
.AutoFit
End With

For J = 3 To LastRow
If Rows(J).RowHeight <= 18 Then Rows(J).RowHeight = 20
Next J
'Application.Goto Range("A1"), Scroll:=True 'Mettre cette ligne en commentaire pour réaliser le TRI est enregistrer à l'endroit souhaité.
Application.EnableEvents = True
End Sub

Bonne fin de soirée à tous
 

Discussions similaires

Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…