Si une ligne non vide, alors aller à la ligne suivante
s
Bonjour à tous,
Je cherche à ajouter un code qui puisse effectuer la chose suivante :
J'ai fait une macro qui fonctionne très bien, le problème aujourd'hui je veux avoir une seule base de donnée au lieu de créer à chaque fois une nouvelle feuille pour chaque tableau de bord.
Comment peut on ajouter sur le code qu il se positionne sur la dernière ligne et il ajoute les nouveaux données.
Est-ce que qq1 peut m'aider ?
Merci bcp d'avance
Soukaina
s
ligneSuivante= Application.ActiveWorkbook.Worksheets("nom de la feuille").Cells(cells.Rows.count, 1).End(xlUp).Row + 1
s
Rebonjour,
Non ça n'a pas marché :s
voici le code que j'utilise
Sub Macro2()
'
' Macro2 Macro
'Sub ESSAI()
'
Dim wk As Workbook
For Each wk In Workbooks
If Workbooks.Count = 1 Then MsgBox "veuillez ouvrir un fichier Tableau de bord et relancer le code": Exit Sub
If Left(wk.Name, 22) = "Tableau de bord appro " Then Workbooks(wk.Name).Activate: Exit For
Next
With ActiveSheet.Range("$A$1:$AU$220682")
.AutoFilter Field:=1, Criteria1:="11222"
.AutoFilter Field:=5, Criteria1:=Array( _
"1", "10", "100", "102", "105", "108", "11", "110", "117", "118", "12", "120", "128", "13", _
"130", "132", "134", "135", "14", "140", "144", "1440", "147", "15", "150", "16", "160", _
"168", "17", "18", "180", "19", "192", "2", "20", "200", "201", "204", "21", "210", "22", _
"23", "24", "246", "25", "252", "26", "27", "28", "280", "288", "3", "30", "300", "308", "32" _
, "33", "330", "336", "34", "35", "36", "37", "39", "4", "40", "42", "420", "432", "44", "45", _
"46", "48", "5", "50", "504", "52", "53", "55", "56", "560", "6", "60", "600", "64", "66", _
"68", "7", "70", "71", "72", "738", "75", "8", "80", "800", "81", "84", "85", "88", "9", "90", _
"92", "96", "98", "99"), Operator:=xlFilterValues
.AutoFilter Field:=6, Criteria1:="<>"
.AutoFilter Field:=7, Criteria1:=Array( _
"1", "1000", "1001", "1008", "1009", "1013", "1020", "1022", "1027", "1030", "1039", _
"1041", "1046", "1059", "1061", "1062", "1072", "1080", "1092", "12", "20", "2000", "21", _
"322", "341", "401", "442", "4898", "869", "879", "899", "965", "966", "967", "978", "980", _
"986", "999"), Operator:=xlFilterValues
.AutoFilter Field:=20, Criteria1:="<>"
Range("T1").Select
ActiveSheet.Range("$A$1:$AU$220288").AutoFilter Field:=20, Criteria1:="<>"
End With
With ActiveSheet
'.Range(.Range("B1"), .Range("B1").End(xlDown)).Copy ThisWorkbook.ActiveSheet.Range("A1") 'Workbooks("OUTIL SUIVI DES RECEPTIONS.xlsx").ActiveSheet.Range("A1")
'.Range(.Range("D1"), .Range("F1").End(xlDown)).Copy ThisWorkbook.ActiveSheet.Range("B1") 'Workbooks("OUTIL SUIVI DES RECEPTIONS.xlsx").ActiveSheet.Range("B1")
'.Range(.Range("T1"), .Range("T1").End(xlDown)).Copy ThisWorkbook.ActiveSheet.Range("E1")
.Range("B1:B" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy ThisWorkbook.ActiveSheet.Range("A1")
.Range("D1:F" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy ThisWorkbook.ActiveSheet.Range("B1")
.Range("T1:T" & .Range("A" & .Rows.Count).End(xlUp).Row).Copy ThisWorkbook.ActiveSheet.Range("E1")
End With
With ThisWorkbook.ActiveSheet
.Range("F1") = "Date_der_recp"
.Range("F2").FormulaR1C1 = "=MID(RC[-1],30,12)"
.Range("F2").AutoFill Destination:=.Range("F2:F4137")
.Range("G1") = "Date_recp_ree"
.Range("G2").FormulaR1C1 = "=MID(RC[-2],3,11)"
.Range("G2").AutoFill Destination:=.Range("G2:G4137")
.Range("H1") = "Qt_RECP"
.Range("H2").FormulaR1C1 = "=MID(RC[-3],27,3)"
.Range("H2").AutoFill Destination:=.Range("H2:H4137")
.Range("I1") = "Qt_ATT"
.Range("I2").FormulaR1C1 = "=MID(RC[-4],18,3)"
.Range("I2").AutoFill Destination:=.Range("I2:I4137")
.Range("J1") = "Nb_colis_recus"
.Range("J2").FormulaR1C1 = "=RC[-2]/RC[-7]"
.Range("J2").AutoFill Destination:=.Range("J2:J4137")
.Range("K1") = "Nb_colis attendus"
.Range("K2").FormulaR1C1 = "=RC[-2]/RC[-8]"
.Range("K2").AutoFill Destination:=.Range("K2:K4137")
.Range("L1") = "Critres"
.Range("L2").FormulaR1C1 = "=MID(RC[-7],1,2)"
.Range("L2").AutoFill Destination:=.Range("L2:L4137")
.Range("M1") = "Ecart(-)"
.Range("M2").FormulaR1C1 = "=IF(RC[-5]-RC[-4]<0,RC[-5]-RC[-4],0)"
.Range("M2").AutoFill Destination:=.Range("M2:M4137")
.Range("N1") = "Ecart(+)"
.Range("N2").FormulaR1C1 = "=IF(RC[-6]-RC[-5]>0,RC[-6]-RC[-5],0)"
.Range("N2").AutoFill Destination:=.Range("N2:N4137")
.Range("O1") = "Nb colis (-)"
.Range("O2").FormulaR1C1 = "=RC[-2]/RC[-12]"
.Range("O2").AutoFill Destination:=.Range("O2:O4137")
.Range("P1") = "Nb colis +"
.Range("P2").FormulaR1C1 = "=RC[-2]/RC[-13]"
.Range("P2").AutoFill Destination:=.Range("P2:P4137")
.Range("Q1") = "Nb colis ok"
.Range("Q2").FormulaR1C1 = "=IF(RC[-5]=""ok"",RC[-7],0)"
.Range("Q2").AutoFill Destination:=.Range("Q2:Q4137")
.Range("R1") = "Nb colis ec"
.Range("R2").FormulaR1C1 = "=IF(RC[-6]=""ec"",RC[-3],0)"
.Range("R2").AutoFill Destination:=.Range("R2:R4137")
.Range("S1") = "Nb colis mq"
.Range("S2").FormulaR1C1 = "=IF(RC[-7]=""mq"",RC[-9],0)"
.Range("S2").AutoFill Destination:=.Range("S2:S4137")
End With
ligneSuivante = Application.ActiveWorkbook.Worksheets("DONNEES").Cells(Cells.Rows.Count, 1).End(xlUp).Row + 1