Très inspiré par le tuto de JB sur la transformation d'une BD en tableau (ici), j'ai un problème avec le code
Code:
Sub BDTableau()
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
Dim Tbl(1 To 100, 1 To 100)
For Each c In Range("a2:a" & [A65000].End(xlUp).Row)
If d1.exists(c.Value) Then lig = d1(c.Value) Else d1(c.Value) = d1.Count + 1: lig = d1.Count
tmp = c.Offset(, 1)
If d2.exists(tmp) Then col = d2(tmp) Else d2(tmp) = d2.Count + 1: col = d2.Count
Tbl(lig, col) = c.Offset(, 2)
Next c
Feuil3.[f2].Resize(d1.Count, 1) = Application.Transpose(d1.keys)
Feuil3. [g1].Resize(1, d2.Count) = d2.keys
Feuil3.[g2].Resize(d1.Count, d2.Count) = Tbl
End Sub
en effet, lorsque je suis sur la feuille contenant la BD, cela fonctionne super bien, par contre, lorsque je suis sur une autre feuille, cela ne fonctionne pas....(je mets en Feuil3 les résultats...).
J'ai essayé
Code:
For Each c In Feuil1.Range("a2:a" & [A65000].End(xlUp).Row)
(BD étant dans Feuil1), mais le code bloque....
Comme la Feuil1 sera masquée, je ne peux pas faire
Code:
Feuil1.select
, j'ai aussi essayé en faisant
Code:
With Feuil1
For Each c In Range("a2:a" & [A65000].End(xlUp).Row)
If d1.exists(c.Value) Then lig = d1(c.Value) Else d1(c.Value) = d1.Count + 1: lig = d1.Count
tmp = c.Offset(, 1)
If d2.exists(tmp) Then col = d2(tmp) Else d2(tmp) = d2.Count + 1: col = d2.Count
Tbl(lig, col) = c.Offset(, 2)
Next c
end with
Très inspiré par le tuto de JB sur la transformation d'une BD en tableau (ici), j'ai un problème avec le code
Code:
Sub BDTableau()
Set d1 = CreateObject("Scripting.Dictionary")
Set d2 = CreateObject("Scripting.Dictionary")
Dim Tbl(1 To 100, 1 To 100)
For Each c In Range("a2:a" & [A65000].End(xlUp).Row)
If d1.exists(c.Value) Then lig = d1(c.Value) Else d1(c.Value) = d1.Count + 1: lig = d1.Count
tmp = c.Offset(, 1)
If d2.exists(tmp) Then col = d2(tmp) Else d2(tmp) = d2.Count + 1: col = d2.Count
Tbl(lig, col) = c.Offset(, 2)
Next c
Feuil3.[f2].Resize(d1.Count, 1) = Application.Transpose(d1.keys)
Feuil3. [g1].Resize(1, d2.Count) = d2.keys
Feuil3.[g2].Resize(d1.Count, d2.Count) = Tbl
End Sub
en effet, lorsque je suis sur la feuille contenant la BD, cela fonctionne super bien, par contre, lorsque je suis sur une autre feuille, cela ne fonctionne pas....(je mets en Feuil3 les résultats...).
J'ai essayé
Code:
For Each c In Feuil1.Range("a2:a" & [A65000].End(xlUp).Row)
(BD étant dans Feuil1), mais le code bloque....
Comme la Feuil1 sera masquée, je ne peux pas faire
Code:
Feuil1.select
, j'ai aussi essayé en faisant
Code:
With Feuil1
For Each c In Range("a2:a" & [A65000].End(xlUp).Row)
If d1.exists(c.Value) Then lig = d1(c.Value) Else d1(c.Value) = d1.Count + 1: lig = d1.Count
tmp = c.Offset(, 1)
If d2.exists(tmp) Then col = d2(tmp) Else d2(tmp) = d2.Count + 1: col = d2.Count
Tbl(lig, col) = c.Offset(, 2)
Next c
end with
C'est effectivement ça qui bloquait.....quel idiot.....je pensais qu'en le mettant devant le Range, cela prenait pour toute la feuille....et ben non...lol
Donc, avec ton éclairage, tout fonctionne parfaitement !! Merci