Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

fonction personalisée decompte valeur tableau mémoire

Hoareau

XLDnaute Occasionnel
Bonjour

J'ai crée un tableau dynamique et une fonction pour décompter les valeurs dans le tableau.

Quand la procedure fait appel à une reference fixe sur la page excel, celma fonctionne

si je fait appel au tableau en mémoire cela me donne des chiffres faux


merci

Public My_Array_Tab_Dynamic() As Variant

Sub tab_Dynamique_ligne()
Application.ScreenUpdating = False

For lig = 6 To 9
For col = 5 To 9


Set mondico = CreateObject("scripting.dictionary")

i = i + 1

ReDim Preserve My_Array_Tab_Dynamic(1 To i)

Set R = Range(Cells(lig, col), Cells(lig, col))


For Each c In R

If Not mondico.exists(c.Value) Then mondico.Add i, c.Value

My_Array_Tab_Dynamic(i) = mondico.Items


Cells(lig, col + 10) = mondico.Items
Cells(lig, col + 20) = mondico.Keys


Cells(lig, 39).Resize(, i) = Application.Transpose(My_Array_Tab_Dynamic)
Next c

Cells(lig, 35) = LBound(My_Array_Tab_Dynamic)
Cells(lig, 36) = UBound(My_Array_Tab_Dynamic)

Next
Next
Application.ScreenUpdating = True
End Sub

"""""""""""""""""""""""""""""""""""""""""""""""
Sub Compte_Valeur_Tableau()
'On Error Resume Next


Dim stat(2, 20)

For i = LBound(stat, 1) To UBound(stat, 1)
For j = LBound(stat, 2) To UBound(stat, 2)

stat(0, j) = j
stat(1, j) = CompteVal(My_Array_Tab_Dynamic, j)

[O15].Resize(2, 20) = stat

Next

Next

End Sub

"""""""""""""""""""""""""""""""""""""""""""""""

Function CompteVal(Plage() As Variant, ByVal T_1 As Integer) As Long

'On Error Resume Next
CompteVal = 0

For a = LBound(Plage, 1) To UBound(Plage, 1)
For b = LBound(Plage, 2) To UBound(Plage, 2)

If Plage(a, b) = T_1 Then CompteVal = CompteVal + 1


Next
Next

End Function
 

Pièces jointes

  • Tab Dybnamique Ligne et Compte valeur dans tableau dynamic VBA _3.xlsm
    29.9 KB · Affichages: 38
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…