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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
Sub test()
Dim DerLig As Long, k As Long, i As Long, Ligne As Long
Dim Wbk1 As Workbook, wbkFin As Workbook
Dim feui As Worksheet
Dim tab2() As Variant
Dim a As Date
Application.DisplayAlerts = False
Set Wbk1 = ThisWorkbook
a = Format(Date, "d/m/yyyy")
a = "2/1/2015"
Workbooks.Open Filename:="\\ISSOU-BI01\Export\ACH\ACH_Archives\ACH-DSI-004-04_Lignes OA en cours et recues depuis 2ans.csv", Local:=True
Set wbkFin = Workbook(Workbooks.Count)
With wbkFin ' sélectionner toutes les feuilles qu'ilya dans le classeur ouvert juste avant
Set feui = .Sheets("ACH-DSI-004-04_Lignes OA en cou")
With feui
DerLig = .Cells(Rows.Count, 10).End(xlUp).Row
.Columns("A:AX").AutoFilter Field:=50, Criteria1:=Array("36E"), Operator:=xlFilterValues
.Columns("A:AX").AutoFilter Field:=4, Criteria1:=Array("Livré"), Operator:=xlFilterValues
.Columns("A:AX").Sort key1:=Range("W2"), order1:=xlAscending, Header:=xlYes
ReDim tab2(1 To DerLig, 1 To 3) ' ca permet d'avoir un tableau à derlig2 ligne et à 4 colonnes
'alimentation du tableau de la feuille 1
Set plageVisible = .UsedRange.SpecialCells(xlCellTypeVisible)
'Set plageVisible = .Range("A1:AX" & Lig).SpecialCells(xlCellTypeVisible)
k = 1
For Each Ligne In plageVisible.Rows
tab2(k, 1) = .Cells(Ligne.Row, 10).Value 'Colonne j
tab2(k, 2) = .Cells(Ligne.Row, 9).Value 'Colonne i
tab2(k, 3) = .Cells(Ligne.Row, 23).Value 'colonne W
k = k + 1
If DateDiff("d", a, tab2(k, 23)) = 0 Then 'Si la date est la même (différence de jours entre les dates = 0)
Exit For
End If
Next Ligne
End With
.Close Savechanges:=False ' fermeture du classeur sans rien modifier
End With
Set feui = Wbk1.Sheets("Feuil4")
With feui
For k = 1 To DerLig
For i = 1 To 3
.Cells(k, i).Value = tab2(k, i)
Next i
Next
.Columns("A:C").AutoFit
End With
End Sub |
Partager