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
|
Function PlageCiblesIdentiques(PlageCibleOrigine As Range, PlageCible As Range) As String
Dim TabloOrigine
Dim Tablo
Dim I As Integer
Dim J As Integer
Dim Chaine1 As String
Dim Chaine2 As String
Dim Retour As String
Application.Volatile
'utilise des tableaux
TabloOrigine = PlageCibleOrigine
Tablo = PlageCible
'remplace les vides par des X
For I = 1 To UBound(TabloOrigine, 2)
If TabloOrigine(1, I) = "" Then TabloOrigine(1, I) = "X"
Next I
'puis concatène
For I = 1 To UBound(TabloOrigine, 2): Chaine1 = Chaine1 & TabloOrigine(1, I): Next I
'boucle
For I = 1 To UBound(Tablo, 1) 'lignes
For J = 1 To UBound(Tablo, 2) 'colonnes
'remplace les vides par des X et concatène
If Tablo(I, J) = "" Then Chaine2 = Chaine2 & "X" Else Chaine2 = Chaine2 & Tablo(I, J)
Next J
'effectue la comparaison, si bon, mémorise l'adresse de la ligne
If InStr(Chaine1, Chaine2) <> 0 Then Retour = Retour & PlageCible.Rows(I).Address(0, 0) & "'"
Chaine2 = ""
Next I
'supprime l'apostrophe de fin
Retour = Left(Retour, Len(Retour) - 1)
'passe à la fonction
PlageCiblesIdentiques = Retour
End Function |
Partager