Bonjour,
Je vous soumet encore une fois un problème que je rencontre.
J'ai une première macro qui me permet d'aller chercher des infos dans une feuille et qui va les coller dans un tableau de synthèse.
Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("Synthèse")
L = Application.Match([c10], .[a:a], 0)
'---mise à jour de la feuille Fiche Achat---
Set Target = Intersect(Target, [c10])
If Not Target Is Nothing Then
Application.EnableEvents = False
If IsError(L) Then
Range("c11:c13,k16,c16,c21,c20,l21,l20,a24") = ""
Else
[c10] = .Range("a" & L)
[c12] = .Range("b" & L)
[c13] = .Range("c" & L)
[k16] = .Range("d" & L)
[c16] = .Range("e" & L)
[c21] = .Range("f" & L)
[c20] = .Range("g" & L)
[l21] = .Range("h" & L)
[l20] = .Range("i" & L)
[a24] = .Range("j" & L)
[o24] = .Range("k" & L)
[j24] = .Range("l" & L)
End If
Application.EnableEvents = True
End If
'---mise à jour de la feuille Synthèse---
If IsError(L) Then L = .[a65536].End(xlUp).Row + 1
If L = 2 Then Exit Sub
.Range("a" & L) = [c10]
.Range("b" & L) = [c12]
.Range("c" & L) = [c13]
.Range("d" & L) = [k16]
.Range("e" & L) = [c16]
.Range("f" & L) = [c21]
.Range("g" & L) = [c20]
.Range("h" & L) = [l21]
.Range("i" & L) = [l20]
.Range("j" & L) = [a24]
.Range("k" & L) = [o24]
.Range("l" & L) = [j24]
End With
End Sub
Et j'aimerais mettre sur la MEMEfeuille une deuxième macro qui permet d'aller chercher des infos sur cette feuille et les mettre dans un deuxième tableau de synthèse. J'ai essayé ça
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheets("PEDIDOS FRS TIERS")
L = Application.Match([c10], .[a:a], 0)
'---mise à jour de la feuille Fiche Achat---
Set Target = Intersect(Target, [c10])
If Not Target Is Nothing Then
Application.EnableEvents = False
If IsError(L) Then
Range("c11:c13,k16,c16,c21,c20,l21,l20,a24") = ""
Else
[c11] = .Range("a" & L)
[c10] = .Range("b" & L)
[c9] = .Range("c" & L)
[k16] = .Range("d" & L)
[l17] = .Range("e" & L)
[b30] = .Range("f" & L)
[d30] = .Range("g" & L)
[n30] = .Range("h" & L)
[p30] = .Range("i" & L)
[r30] = .Range("j" & L)
[h20] = .Range("k" & L)
[h21] = .Range("n" & L)
[c12] = .Range("o" & L)
End If
Application.EnableEvents = True
End If
'---mise à jour de la feuille Synthèse---
If IsError(L) Then L = .[a65536].End(xlUp).Row + 1
If L = 2 Then Exit Sub
.Range("a" & L) = [c11]
.Range("b" & L) = [c10]
.Range("c" & L) = [c9]
.Range("d" & L) = [k16]
.Range("e" & L) = [l17]
.Range("f" & L) = [b30]
.Range("g" & L) = [d30]
.Range("h" & L) = [n30]
.Range("i" & L) = [p30]
.Range("j" & L) = [r30]
.Range("k" & L) = [h20]
.Range("n" & L) = [h21]
.Range("o" & L) = [c12]
End With
End Sub
J'ai rajouter Selection dans le nom de la macro pour ne pas avoir l'erreur "nom ambigu détecté" seulement quand des modifications sont effectuées sur la page de départ, cela créer plusieurs fois la ligne dans le deuxième tableau de synthèse. Ce n'était peut être pas la bonne solution de rajouter Selection devant Change(ByVal Target As Range)
M%erci pour votre aide
Je vous soumet encore une fois un problème que je rencontre.
J'ai une première macro qui me permet d'aller chercher des infos dans une feuille et qui va les coller dans un tableau de synthèse.
Private Sub Worksheet_Change(ByVal Target As Range)
With Sheets("Synthèse")
L = Application.Match([c10], .[a:a], 0)
'---mise à jour de la feuille Fiche Achat---
Set Target = Intersect(Target, [c10])
If Not Target Is Nothing Then
Application.EnableEvents = False
If IsError(L) Then
Range("c11:c13,k16,c16,c21,c20,l21,l20,a24") = ""
Else
[c10] = .Range("a" & L)
[c12] = .Range("b" & L)
[c13] = .Range("c" & L)
[k16] = .Range("d" & L)
[c16] = .Range("e" & L)
[c21] = .Range("f" & L)
[c20] = .Range("g" & L)
[l21] = .Range("h" & L)
[l20] = .Range("i" & L)
[a24] = .Range("j" & L)
[o24] = .Range("k" & L)
[j24] = .Range("l" & L)
End If
Application.EnableEvents = True
End If
'---mise à jour de la feuille Synthèse---
If IsError(L) Then L = .[a65536].End(xlUp).Row + 1
If L = 2 Then Exit Sub
.Range("a" & L) = [c10]
.Range("b" & L) = [c12]
.Range("c" & L) = [c13]
.Range("d" & L) = [k16]
.Range("e" & L) = [c16]
.Range("f" & L) = [c21]
.Range("g" & L) = [c20]
.Range("h" & L) = [l21]
.Range("i" & L) = [l20]
.Range("j" & L) = [a24]
.Range("k" & L) = [o24]
.Range("l" & L) = [j24]
End With
End Sub
Et j'aimerais mettre sur la MEMEfeuille une deuxième macro qui permet d'aller chercher des infos sur cette feuille et les mettre dans un deuxième tableau de synthèse. J'ai essayé ça
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Sheets("PEDIDOS FRS TIERS")
L = Application.Match([c10], .[a:a], 0)
'---mise à jour de la feuille Fiche Achat---
Set Target = Intersect(Target, [c10])
If Not Target Is Nothing Then
Application.EnableEvents = False
If IsError(L) Then
Range("c11:c13,k16,c16,c21,c20,l21,l20,a24") = ""
Else
[c11] = .Range("a" & L)
[c10] = .Range("b" & L)
[c9] = .Range("c" & L)
[k16] = .Range("d" & L)
[l17] = .Range("e" & L)
[b30] = .Range("f" & L)
[d30] = .Range("g" & L)
[n30] = .Range("h" & L)
[p30] = .Range("i" & L)
[r30] = .Range("j" & L)
[h20] = .Range("k" & L)
[h21] = .Range("n" & L)
[c12] = .Range("o" & L)
End If
Application.EnableEvents = True
End If
'---mise à jour de la feuille Synthèse---
If IsError(L) Then L = .[a65536].End(xlUp).Row + 1
If L = 2 Then Exit Sub
.Range("a" & L) = [c11]
.Range("b" & L) = [c10]
.Range("c" & L) = [c9]
.Range("d" & L) = [k16]
.Range("e" & L) = [l17]
.Range("f" & L) = [b30]
.Range("g" & L) = [d30]
.Range("h" & L) = [n30]
.Range("i" & L) = [p30]
.Range("j" & L) = [r30]
.Range("k" & L) = [h20]
.Range("n" & L) = [h21]
.Range("o" & L) = [c12]
End With
End Sub
J'ai rajouter Selection dans le nom de la macro pour ne pas avoir l'erreur "nom ambigu détecté" seulement quand des modifications sont effectuées sur la page de départ, cela créer plusieurs fois la ligne dans le deuxième tableau de synthèse. Ce n'était peut être pas la bonne solution de rajouter Selection devant Change(ByVal Target As Range)
M%erci pour votre aide