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
| Sub Test2()
Dim Phrase As String
Dim I As Long, J As Long, Depart As Long, Longueur As Long, DerniereLigne As Long, IndexMatrice As Long
Dim AireABalayer As Range
Dim TableauAccolades As Variant
Dim MatriceAccolades() As Variant
With ActiveSheet
DerniereLigne = .Cells(.Rows.Count, 1).End(xlUp).Row
Set AireABalayer = .Range("A1:A" & DerniereLigne)
IndexMatrice = 0
For I = 1 To AireABalayer.Count
Depart = 0: Longueur = 0
With AireABalayer(I)
TableauAccolades = Split(.Value, "{")
If UBound(TableauAccolades) > 0 Then
For J = LBound(TableauAccolades) To UBound(TableauAccolades)
Debug.Print I & ", " & TableauAccolades(J)
If InStr(1, TableauAccolades(J), "}", vbTextCompare) > 0 Then
ReDim Preserve MatriceAccolades(2, IndexMatrice)
MatriceAccolades(0, IndexMatrice) = I
MatriceAccolades(1, IndexMatrice) = Split(TableauAccolades(J), "}")(0)
IndexMatrice = IndexMatrice + 1
End If
Next J
End If
End With
Next I
For IndexMatrice = LBound(MatriceAccolades, 2) To UBound(MatriceAccolades, 2)
Debug.Print "Ligne : " & MatriceAccolades(0, IndexMatrice) & " : " & MatriceAccolades(1, IndexMatrice)
Next IndexMatrice
' Ensuite on recherche dans chaque cellule de l'aire AireABalayer
' les chaînes contenues dans la matrice correspondant à la ligne dans MatriceAccolades(0, IndexMatrice)
' et avec Instr la présence de MatriceAccolades(1, IndexMatrice) dans la chaînes
Set AireABalayer = Nothing
End With
End Sub |
Partager