Bonjour à tous,

je viens d'essayer de réaliser un algorithme afin de trouver les champs qui sont affectés à une valeur dans un tableau .

Pour illustre:
colA___col B_Col c_Col d_Col e__col f__col g
_____________________________________
AA_____123______________________________
BB______12______________________________
AA_____15_____________________________
CC_____125___________________________
CC_____4_____________________________
AA_____ 8______________________________
BB_____4______________________________
AA ____9______________________________


J'aimerai que ca me retourne
colA___col B_Col c_Col d_Col e__col f__col g
_____________________________________
AA___123_______________15____8____9
BB____12________________4___________
AA____15________________8____9 ______
CC____125_______________4____________
CC_____4_____________________________
AA____8_________________9____________
BB____4______________________________
AA ___9______________________________
Voici mon algroithme:
Qu'est ce qui cloche?

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
Sub test1()
 
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim nblig As Integer
 
Dim vara As String
Dim varb As String
Dim varc As String
 
nblig = Range(Selection, Selection.End(xlDown)).Rows.Count
 
Range("A1").Select
For i = 1 To nblig
vara = Cells("A" & i).Value
 
        Do While j < nblig
        varb = Cells("A" & j).Value
        varc = Cells("B" & j).Value
            If vara = varb Then
            Cells(i, k).Value = varc
            k = k + 1
            j = j + 1
            Else
            j = j + 1
            End If
            K + 5
        Loop
Next i
 
End Sub
Merci pour votre aide,

azerty5