Bonjour à tous,
j'essaye de trier des dates de la plus ancienne à la plus récente mais j'ai une erreur "référence de tri non valdie et je ne comprends pas pourquoi...
Pouvez-vous m'aider svp?
voici mon code:
En fait, je transfert dès qu'il y a une date dans la colonne A de la feuille "en cours" les valeur dans la feuille "clos" et j'aimerais une fois le transfert terminé que cela soit trié de la plus ancienne à la plus récente.
Code : Sélectionner tout - Visualiser dans une fenêtre à part Workbooks("suivi investigations").Sheets("clos").Range("A" & LigDeb & ":V" & LigFinCLOS).Sort Key1:=Range("A1"), Order1:=xlAscending
voici mon code entier:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 Sub TransFertCLOS() Dim LigFinCOURS As Long Dim LigFinCLOS As Long Dim LigDeb As Long Dim C As Range Dim i As Integer Dim n As Integer X = MsgBox("Êtes-vous sur de vouloir transférer les données closes ? Cette opération peut prendre plusieurs minutes", vbYesNo, "transfert des données closes") If X = vbNo Then Exit Sub End If If Workbooks("suivi investigations").Sheets("en cours").AutoFilterMode = True Then Workbooks("suivi investigations").Sheets("en cours").AutoFilterMode = False End If If Workbooks("suivi investigations").Sheets("clos").AutoFilterMode = True Then Workbooks("suivi investigations").Sheets("clos").AutoFilterMode = False End If Application.ScreenUpdating = False LigFinCOURS = Workbooks("suivi investigations").Sheets("en cours").Cells(Rows.Count, 3).End(xlUp).Row + 1 LigDeb = 2 LigFinCLOS = Workbooks("suivi investigations").Sheets("clos").Cells(Rows.Count, 3).End(xlUp).Row + 1 Application.ScreenUpdating = False For i = LigFinCOURS To LigDeb Step -1 If Workbooks("suivi investigations").Sheets("en cours").Cells(i, 1).Value <> "" Then LigFinCLOS = Workbooks("suivi investigations").Sheets("clos").Cells(Rows.Count, 3).End(xlUp).Row + 1 Workbooks("suivi investigations").Sheets("en cours").Cells(i, 1).EntireRow.Copy Workbooks("suivi investigations").Sheets("clos").Range("A" & LigFinCLOS) Workbooks("suivi investigations").Sheets("en cours").Cells(i, 1).EntireRow.Delete End If Next i LigFinCLOS = Workbooks("suivi investigations").Sheets("clos").Cells(Rows.Count, 3).End(xlUp).Row + 1 If LigDeb <> LigFinCLOS Then Workbooks("suivi investigations").Sheets("clos").Range("A" & LigDeb & ":V" & LigFinCLOS).Sort Key1:=Range("A1"), Order1:=xlAscending End If Workbooks("suivi investigations").Sheets("en cours").Range("A1:V1").AutoFilter Workbooks("suivi investigations").Sheets("clos").Range("A1:V1").AutoFilter End Sub
merci d'avance de votre aide
Partager