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
| <ol style="list-style-type: decimal"><li>Sub GenererIdAnonyme()</li>
<li>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</li>
<li>' '</li>
<li>' GénérerIdAnonyme Macro '</li>
<li>' Ce macro fait une correspondance entre les numéros des candidats et les numéros anonymes générés.'</li>
<li>' '</li>
<li>''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</li>
<li>Dim typeConcours As String</li>
<li>typeConcours = DA 'DA= Directe A</li>
<li>Dim feuil_dest As String</li>
<li>feuil_dest = "Correspondance"</li>
<li>Dim pointeur_feuil_dest As Integer</li>
<li>pointeur_feuil_dest = 1</li>
<li>Dim feuil_debut As String</li>
<li>feuil_debut = "PRE SELECTION"</li>
<li>Dim pointeur_feuil_debut As Integer</li>
<li>pointeur_feuil_debut = 1
</li>
<li>Dim nbTotalCandidats As Integer</li>
<li>Dim nbTotalCand1 As Integer</li>
<li>Dim nbTotalCand2 As Integer</li>
<li>Dim nbTotalCand3 As Integer</li>
<li>nbTotalCand1 = 500</li>
<li>nbTotalCand2 = 1000</li>
<li>nbTotalCand3 = 1500</li>
<li>nbTotalCandidats = 1500
</li>
<li>Dim order As Integer
</li>
<li>With Sheets(feuil_debut)</li>
<li>cpt_PFD = pointeur_feuil_debut</li>
<li>order = pointeur_feuil_dest</li>
<li>For Each cell In .Range("A:A").Cells</li>
<li>If Not cell.value = "" Then</li>
<li>.Range("A" & cpt_PFD).Copy Destination:=Sheets(feuil_dest).Range("A" & order)</li>
<li>If order <= nbTotalCand1 Then</li>
<li>Sheets(feuil_dest).Range("B" & cpt_PFD).value = getIdAnonyme(cell.value, 1)</li>
<li>Else</li>
<li>If order <= nbTotalCand2 Then</li>
<li>Sheets(feuil_dest).Range("B" & cpt_PFD).value = getIdAnonyme(cell.value, 2)</li>
<li>Else</li>
<li>If order <= nbTotalCand3 Then</li>
<li>Sheets(feuil_dest).Range("B" & cpt_PFD).value = getIdAnonyme(cell.value, 3)</li>
<li>End If</li>
<li>End If</li>
<li>End If</li>
<li>.Range("B" & cpt_PFD).Copy Destination:=Sheets(feuil_dest).Range("C" & order)</li>
<li>.Range("C" & cpt_PFD).Copy Destination:=Sheets(feuil_dest).Range("D" & order)</li>
<li>.Range("D" & cpt_PFD).Copy Destination:=Sheets(feuil_dest).Range("E" & order)</li>
<li>.Range("E" & cpt_PFD).Copy Destination:=Sheets(feuil_dest).Range("F" & order)</li>
<li>.Range("F" & cpt_PFD).Copy Destination:=Sheets(feuil_dest).Range("G" & order)</li>
<li>order = order + 1</li>
<li>End If</li>
<li>If cpt_PFD <= (nbTotalCandidats + pointeur_feuil_debut + 1) Then</li>
<li>cpt_PFD = cpt_PFD + 1</li>
<li>Else</li>
<li>Exit Sub</li>
<li>End If</li>
<li>Next cell</li>
<li>End With</li>
<li>End Sub
</li>
<li>Function getIdAnonyme(id As String, ind As Integer)</li>
<li>' Algo: On considére un tableau de 10 elements fixés. Les indices du tabeau varient alors de 0 à 9</li>
<li>' ce qui constituent les différents combinaisons de chiffres possible pour identifier un candidat.</li>
<li>' Le candidat de numéro 309 aura comme IdAnonyme la concaténation des elements du tableau aux positions</li>
<li>' respectives 3, 0 et 9 ie idAnonymyme=tab(3)+tab(0)+tab(9) LAs
</li>
<li>Dim elmt1() As Variant</li>
<li>Dim elmt2() As Variant</li>
<li>Dim elmt3() As Variant</li>
<li>elmt1 = Array("YB13", "Tnt", "Lj", "Ghft", "Cn", "Tv", "2i", "Zm", "y", "s")</li>
<li>elmt2 = Array("Ru", "Z", "2a", "Vp", "N", "Kh", "Zi", "Pi", "Ev", "F2")</li>
<li>elmt3 = Array("Do", "Bo", "0k", "3r", "5", "Ph", "Br", "li", "5", "2")</li>
<li>Dim idGenerated As String</li>
<li>idGenerated = Mid(id, 1, 1)</li>
<li>For cp = 2 To (Len(id)) ' A revoir source d'erreur : la fin de boucle</li>
<li>If Not Mid(id, cp, 1) = "." Then</li>
<li>If ind = 1 Then</li>
<li>idGenerated = idGenerated + elmt1(Val(Mid(id, cp, 1)))</li>
<li>End If</li>
<li>If ind = 2 Then</li>
<li>idGenerated = idGenerated + elmt2(Val(Mid(id, cp, 1)))</li>
<li>End If</li>
<li>If ind = 3 Then</li>
<li>idGenerated = idGenerated + elmt3(Val(Mid(id, cp, 1)))</li>
<li>End If</li>
<li>End If</li>
<li>Next</li>
<li>getIdAnonyme = idGenerated</li>
<li>End Function</li>
</ol> |