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
| Sub Traitement(Cel As Range)
Dim Operateurs As Object
Dim Result As Range, NL As Range
Dim TabTemp As Variant, N As Variant, S As Variant
Dim Ateliers As String, Atelier As String, Statut As String
Dim L As Long, Lmax As Long
Dim C As Integer
Dim Car As Byte
Application.ScreenUpdating = False
'Extrait les ateliers concernés (sans séparateur)
Ateliers = Replace(Cel.Offset(0, -3).Text, "-", "")
With Sheets("Habilitations")
'Mémorise le tableau des opérateurs
C = .Range("IV2").End(xlToLeft).Column
L = .Range("A65536").End(xlUp).Row
TabTemp = .Range(.Cells(2, 1), .Cells(L, C))
Set Operateurs = CreateObject("Scripting.Dictionary")
'Pour chaque Atelier à trouver
For Car = 1 To Len(Ateliers) Step 2
Atelier = Mid(Ateliers, Car, 2)
For C = 3 To UBound(TabTemp, 2)
If TabTemp(1, C) = Atelier Then
For L = 5 To UBound(TabTemp, 1)
If TabTemp(L, C) <> "" Then
'"Collecte" les statuts et noms des opérateurs (sans doublon)
On Error Resume Next
Operateurs.Add TabTemp(L, 2), TabTemp(L, 1)
On Error GoTo 0
End If
Next L
Exit For
End If
Next C
Next Car
End With
'MAJ résultats
With Sheets("Edition Nom")
.Range("A8:C65536").Delete
Set Result = .Range("A8:B65536")
.Cells(4, 1).Value = Cel.Text
S = Operateurs.items
N = Operateurs.keys
For L = 0 To Operateurs.Count - 1
.Cells(L + 8, 1).Value = S(L) 'Statuts
.Cells(L + 8, 2).Value = N(L) 'Noms
Next L
'Tri
Result.Sort Key1:=.Range("A8"), Order1:=xlAscending, Key2:=.Range("B8") _
, Order2:=xlAscending
'Mise en forme
Lmax = .Range("B65536").End(xlUp).Row
Set Result = .Range(.Cells(8, 1), .Cells(Lmax, 3))
Result.Borders.LineStyle = xlContinuous
End With
Sheets("Edition Nom").Visible = True
' Imprime l'onglet "Edition Nom" et le supprime
'Sheets("Edition Nom").Select
'Application.CutCopyMode = False
'ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
' Rend invisible l'onglet "Edition Nom"
'ActiveWindow.SelectedSheets.Visible = True
'Sheets("Procédures").Select
End Sub |
Partager