Boucle VBA

Holà todos,

Je galère un peu en VBA ^^

Il me faudrait un compteur qui compte le nombre de fois qu'un mot apparait (ici satisfait)

et dès que ce mot apparait dans la colonne A il prend le commentaire associé de la colonne B et le colle dans la feuille d'a coté

Merci beaucoup

39classeur2.xlsx (14.47 Ko)

Bonjour,

je ne suis pas certaine d'avoir bien compris, tu me dit si ça ne vas pas,

Sub Macro1()
 Dim Avis, sh1, sh2, n As Integer, i As Integer, col As Integer
 Dim sh1LastRw As Long, sh2LastRw As Long

 Set sh1 = Sheets("Feuil1")
 Set sh2 = Sheets("Feuil2")
 sh1LastRw = sh1.Cells(Rows.Count, 1).End(xlUp).Row
 sh2LastRw = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
 Avis = Array("Très Satisfait", "Satifait", "Satisfait", "Moyennement satisfait", "Pas du tout satisfait", "N'achete pas")

    For col = 1 To 3 Step 2
     For n = 0 To 5
       For i = 2 To sh1LastRw
        If sh1.Cells(i, col) = Avis(n) Then
         sh2.Cells(sh2LastRw, 1) = sh1.Cells(i, col + 1)
         sh2.Cells(sh2LastRw, 2) = sh1.Cells(i, col)
         sh2.Cells(sh2LastRw, 3) = sh1.Cells(1, col)
         sh2LastRw = sh2.Cells(Rows.Count, 1).End(xlUp).Row + 1
        End If
       Next i
     Next n
    Next col
End Sub

Yees super merci

Rechercher des sujets similaires à "boucle vba"