Re : Extraction de données avec plusieurs variables
Hello
avec ce code dans un module standard vba (Alt +F11 pour ouvrir l'éditeur)
à gauche: clic droit, ajouter module
et tu colles le code ci dessous
1) ca va bien marcher pour supprimer les lignes inutiles
Sub Macro1()
'
' Macro1 Macro
'créer une zone nommée dynamiquement TabData
ActiveWorkbook.Names.Add Name:="TabData", RefersToR1C1:= _
"=OFFSET(AuditTrail!R2C1,,,COUNTA(AuditTrail!C1)-1,5)"
'ActiveWorkbook.Names("TabData").Comment = ""
'suppression des lignes contenant Porte ouverte (gâche)
For i = Range("TabData").Rows.Count To 2 Step -1
If Cells(i, "C") = "Porte ouverte (gâche)" Then
Rows(i).Delete
End If
Next i
nb = Range("TabData").Rows.Count
For i = 2 To nb Step 2
User = Cells(i, "D")
JourEntrée = Day(WorksheetFunction.Substitute(Cells(i, "A"), ".", "/"))
'JourEntrée = Day(Cells(i, "A"))
JourSortie = Day(WorksheetFunction.Substitute(Cells(i + 1, "A"), ".", "/"))
If Not (Cells(i + 1, "D") = User And JourSortie = JourEntrée And Cells(i + 1, "C") = "< Porte ouverte (clé)") Then
Cells(i, "F") = "PAS SORTI"
i = i - 1
End If
Next i
End Sub
[/code]