B
bbell
Guest
Bonsoir à tous, j'ai un petit souci avec une macro, un grand merci pour votre aide.
Je veux récupérer des données depuis un tableau croisé dynamique. Ma macro :
Sub TRANSFERT()
Dim i As Integer
Dim a As Integer
Dim b As Integer
Dim valeur As String
i = 3
Do Until Cells(i, 4) = ""
valeur = Cells(i, 4)
Cells(i, 5) = trouveIW(valeur, 3) 'Stock
i = i + 1
Loop
i = 3
a = 7
b = 4
Do Until Cells(i, 4) = ""
valeur = Cells(i, 4)
Cells(i, a) = trouveIW(valeur, b) 'Echu + 05S11 + 06S11 + 07S11 + 08S11
a = a + 1
b = b + 1
i = i + 1
Loop
End Sub
Function trouveIW(valeur As String, colonne As Integer)
Dim j As Integer
Dim trouve As String
Sheets("TCD").Select
j = 6
trouve = ""
Do Until Cells(j, 1) = "" Or trouve <> ""
If Cells(j, 1) = valeur Then
trouve = Cells(j, colonne)
End If
j = j + 1
Loop
trouveIW = trouve
Sheets("Tableau").Select
End Function
Ci-joint mon fichier Excel pour plus de détails.
Merci encore
Je veux récupérer des données depuis un tableau croisé dynamique. Ma macro :
Sub TRANSFERT()
Dim i As Integer
Dim a As Integer
Dim b As Integer
Dim valeur As String
i = 3
Do Until Cells(i, 4) = ""
valeur = Cells(i, 4)
Cells(i, 5) = trouveIW(valeur, 3) 'Stock
i = i + 1
Loop
i = 3
a = 7
b = 4
Do Until Cells(i, 4) = ""
valeur = Cells(i, 4)
Cells(i, a) = trouveIW(valeur, b) 'Echu + 05S11 + 06S11 + 07S11 + 08S11
a = a + 1
b = b + 1
i = i + 1
Loop
End Sub
Function trouveIW(valeur As String, colonne As Integer)
Dim j As Integer
Dim trouve As String
Sheets("TCD").Select
j = 6
trouve = ""
Do Until Cells(j, 1) = "" Or trouve <> ""
If Cells(j, 1) = valeur Then
trouve = Cells(j, colonne)
End If
j = j + 1
Loop
trouveIW = trouve
Sheets("Tableau").Select
End Function
Ci-joint mon fichier Excel pour plus de détails.
Merci encore
Pièces jointes
Dernière modification par un modérateur: