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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
| Sub Macro1()
' ---------Export vers feuille2
Application.ScreenUpdating = False
Set ws_user = Sheets("utilisateurs")
Set ws_CM2 = Sheets("vit")
Set ws_CM1 = Sheets("CM1")
NbLigCM1 = ws_CM1.[A1].CurrentRegion.Rows.Count
NbParam = ws_user.[K1].CurrentRegion.Rows.Count
NbLigCM2 = ws_CM2.[A1].CurrentRegion.Rows.Count - 1
NbExport = 0
For i = 2 To NbParam
For j = 2 To NbLigCM1
If (ws_CM1.Cells(j, "K") = ws_user.Cells(i, "K")) Then
ws_CM1.Rows(j).Copy Destination:=ws_CM2.Rows(2 + NbLigCM2)
NbLigCM2 = NbLigCM2 + 1
NbExport = NbExport + 1
ws_CM1.Rows(j).Delete
j = j - 1
End If
Next
Next
Application.ScreenUpdating = True
'----------------Export vers feuille3
Application.ScreenUpdating = False
Set ws_user = Sheets("utilisateurs")
Set ws_CM3 = Sheets("dar")
Set ws_CM1 = Sheets("CM1")
NbLigCM1 = ws_CM1.[A1].CurrentRegion.Rows.Count
NbParam = ws_user.[K1].CurrentRegion.Rows.Count
NbLigCM3 = ws_CM3.[A1].CurrentRegion.Rows.Count - 1
NbExport = 0
For i = 2 To NbParam
For j = 2 To NbLigCM1
If (ws_CM1.Cells(j, "K") = ws_user.Cells(i, "L")) Then
ws_CM1.Rows(j).Copy Destination:=ws_CM3.Rows(2 + NbLigCM3)
NbLigCM3 = NbLigCM3 + 1
NbExport = NbExport + 1
ws_CM1.Rows(j).Delete
j = j - 1
End If
Next
Next
Application.ScreenUpdating = True
'----------------Export vers feuille4
Application.ScreenUpdating = False
Set ws_user = Sheets("utilisateurs")
Set ws_CM4 = Sheets("arr")
Set ws_CM1 = Sheets("CM1")
NbLigCM1 = ws_CM1.[A1].CurrentRegion.Rows.Count
NbParam = ws_user.[K1].CurrentRegion.Rows.Count
NbLigCM4 = ws_CM4.[A1].CurrentRegion.Rows.Count - 1
NbExport = 0
For i = 2 To NbParam
For j = 2 To NbLigCM1
If (ws_CM1.Cells(j, "K") = ws_user.Cells(i, "M")) Then
ws_CM1.Rows(j).Copy Destination:=ws_CM4.Rows(2 + NbLigCM4)
NbLigCM4 = NbLigCM4 + 1
NbExport = NbExport + 1
ws_CM1.Rows(j).Delete
j = j - 1
End If
Next
Next
Application.ScreenUpdating = True
'-------Export vers feuille5
Application.ScreenUpdating = False
Set ws_user = Sheets("utilisateurs")
Set ws_CM5 = Sheets("cre")
Set ws_CM1 = Sheets("CM1")
NbLigCM1 = ws_CM1.[A1].CurrentRegion.Rows.Count
NbParam = ws_user.[K1].CurrentRegion.Rows.Count
NbLigCM5 = ws_CM5.[A1].CurrentRegion.Rows.Count - 1
NbExport = 0
For i = 2 To NbParam
For j = 2 To NbLigCM1
If (ws_CM1.Cells(j, "K") = ws_user.Cells(i, "N")) Then
ws_CM1.Rows(j).Copy Destination:=ws_CM5.Rows(2 + NbLigCM5)
NbLigCM5 = NbLigCM5 + 1
NbExport = NbExport + 1
ws_CM1.Rows(j).Delete
j = j - 1
End If
Next
Next
Application.ScreenUpdating = True
End Sub |
Partager