VBA - 다중 시트 피벗 테이블을 만드는 매크로
VBA - 다중 시트 피벗 테이블을 만드는 매크로
이 가이드에서는 2 차원 배열 (변수)에서 "사전"개체를 사용합니다.
통합 문서
판매, 월별, 판매원 및 판매 된 제품을 재 그룹화하는 통합 문서.
통합 문서에는 매월 한 장씩 12 장이 들어 있습니다.
각 시트에는 3 개의 열이 있습니다.
- 열 A : 세일즈맨의 이름,
- B 열 : 판매 된 제품의 이름,
- C 열 : 금액입니다.
VBA 코드
VBA를 통합 문서에 통합하려면 아래의 전체 코드를 복사하십시오.
- Alt + F11을 누릅니다.
- 삽입 / 모듈 클릭
- 코드를 붙여 넣습니다.
통합 문서로 돌아가려면 Visual Basic Editor를 닫은 다음 Alt + F8을 누르고 " RécapAvecSommeDesColonnesC "를 선택한 다음 "실행"을 클릭하십시오.
편의성 변경 :
- 격판 덮개 장의 이름
- "원본"열 : A, B 및 C
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
Option Explicit Sub RécapAvecSommeDesColonnesC() Dim Feuille As Worksheet, i As Long Dim TablVendeurs(), DicoVendeurs As Object Dim TablVentes(), DicoVentes As Object Dim Sommes() Set DicoVendeurs = CreateObject("Scripting.Dictionary") Set DicoVentes = CreateObject("Scripting.Dictionary") '*******REMPLISSAGE DES OBJETS DITIONARY ET VARIABLES******* 'remplissage des étiquettes de lignes et de colonnes sans doublons For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille TablVendeurs = .Range("A2", .Range("A" & Rows.Count).End(xlUp)) For i = LBound(TablVendeurs, 1) To UBound(TablVendeurs, 1) If Not DicoVendeurs.exists(TablVendeurs(i, 1)) Then DicoVendeurs.Add TablVendeurs(i, 1), TablVendeurs(i, 1) Next i TablVentes = .Range("B2", .Range("B" & Rows.Count).End(xlUp)) For i = LBound(TablVentes, 1) To UBound(TablVentes, 1) If Not DicoVentes.exists(TablVentes(i, 1)) Then DicoVentes.Add TablVentes(i, 1), TablVentes(i, 1) Next i End With End If Next Feuille 'remplissage de la variable tableau 2D grâce aux clés de Dictionary ReDim Sommes(1 To DicoVendeurs.Count, 1 To DicoVentes.Count) For Each Feuille In ThisWorkbook.Worksheets If Feuille.Name "Récap" Then With Feuille For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) = Sommes(Application.Match(.Cells(i, 1), DicoVendeurs.keys, 0), Application.Match(.Cells(i, 2), DicoVentes.keys, 0)) + .Range("C" & i).Value Next i End With End If Next Feuille '*******RESTITUTION DES DONNEES******* With Sheets("Récap") .Range("A2").Resize(DicoVendeurs.Count, 1) = Application.Transpose(DicoVendeurs.keys) .Range("B1").Resize(1, DicoVentes.Count) = DicoVentes.keys .Range("B2").Resize(UBound(Sommes, 1), UBound(Sommes, 2)) = Sommes() End With End Sub
링크 다운로드
샘플 시트를 다운로드 할 수 있습니다.
- 샘플 시트 형식 .xlsm (Excel> 2007) - 1, 19 Mo
- 샘플 시트 형식 .xls (Excel <2007) - 3, 86 Mo