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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
| Option Explicit
Sub comparatif_donnees_lanceur()
Dim colonne_cours As Long
Dim nbre_lignes_max_colonne_cours As Long
Dim nbre_lignes_max_mh_entrant As Long
Dim nbre_lignes_max_mh_sortant As Long
Dim tablo_entrant()
Dim tablo_sortant()
Dim tablo_final()
Dim index_tablo_entrant As Long
Dim index_tablo_sortant As Long
Dim index_1_tablo_final As Long
Dim index_2_tablo_final As Long
Dim cle_cours As Variant
Dim dico_entrant As Dictionary
Set dico_entrant = New Dictionary
Dim dico_sortant As Dictionary
Set dico_sortant = New Dictionary
On Error Resume Next
Sheets("Listing_vide_chaine").ShowAllData
Sheets("MH ENTRANT").ShowAllData
Sheets("MH SORTANT").ShowAllData
On Error GoTo 0
Sheets("Listing_vide_chaine").Columns("A:XFD").EntireColumn.Hidden = False
Sheets("Listing_vide_chaine").Rows("1:1048576").EntireRow.Hidden = False
Sheets("MH ENTRANT").Columns("A:XFD").EntireColumn.Hidden = False
Sheets("MH ENTRANT").Rows("1:1048576").EntireRow.Hidden = False
Sheets("MH SORTANT").Columns("A:XFD").EntireColumn.Hidden = False
Sheets("MH SORTANT").Rows("1:1048576").EntireRow.Hidden = False
Sheets("Listing_vide_chaine").Range("A2:XFD1048576").Clear
For colonne_cours = 1 To 5
nbre_lignes_max_colonne_cours = Sheets("MH ENTRANT").Cells(1048576, colonne_cours).End(xlUp).Row
If nbre_lignes_max_colonne_cours > nbre_lignes_max_mh_entrant Then
nbre_lignes_max_mh_entrant = nbre_lignes_max_colonne_cours
End If
Next colonne_cours
For colonne_cours = 1 To 5
nbre_lignes_max_colonne_cours = Sheets("MH SORTANT").Cells(1048576, colonne_cours).End(xlUp).Row
If nbre_lignes_max_colonne_cours > nbre_lignes_max_mh_sortant Then
nbre_lignes_max_mh_sortant = nbre_lignes_max_colonne_cours
End If
Next colonne_cours
If nbre_lignes_max_mh_entrant > 1 And nbre_lignes_max_mh_sortant > 1 Then
tablo_entrant() = Sheets("MH ENTRANT").Range("A2:F" & nbre_lignes_max_mh_entrant).Value
tablo_sortant() = Sheets("MH SORTANT").Range("A2:F" & nbre_lignes_max_mh_sortant).Value
ReDim tablo_final(nbre_lignes_max_mh_entrant + nbre_lignes_max_mh_sortant - 1, 5)
For index_tablo_entrant = 1 To nbre_lignes_max_mh_entrant - 1
dico_entrant(tablo_entrant(index_tablo_entrant, 1) & " | " & tablo_entrant(index_tablo_entrant, 3)) = index_tablo_entrant + 1
Next index_tablo_entrant
For index_tablo_sortant = 1 To nbre_lignes_max_mh_sortant - 1
dico_sortant(tablo_sortant(index_tablo_sortant, 1) & " | " & tablo_sortant(index_tablo_sortant, 3)) = index_tablo_sortant + 1
Next index_tablo_sortant
' For Each cle_cours In dico_entrant.Keys
' If Not dico_sortant.Exists(cle_cours) Then
' For index_2_tablo_final = 0 To 5
' tablo_final(index_1_tablo_final, index_2_tablo_final) = tablo_entrant(dico_entrant(cle_cours), index_2_tablo_final + 1)
' Next index_2_tablo_final
' index_1_tablo_final = index_1_tablo_final + 1
' End If
' Next cle_cours
For Each cle_cours In dico_sortant.Keys
If Not dico_entrant.Exists(cle_cours) Then
For index_2_tablo_final = 0 To 5
tablo_final(index_1_tablo_final, index_2_tablo_final) = tablo_sortant(dico_sortant(cle_cours), index_2_tablo_final + 1)
Next index_2_tablo_final
index_1_tablo_final = index_1_tablo_final + 1
End If
Next cle_cours
If index_1_tablo_final > 0 Then
Sheets("Listing_vide_chaine").Range("A2:F" & index_1_tablo_final + 1) = tablo_final
End If
End If
MsgBox "Comparaison terminée", vbInformation, "C'est fait"
End Sub |
Partager