1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
| Public Function ListeConsoElec(C As Range, ListCompteurRatio As CompteurRatio)
Dim A(3)
Dim N As Single
Dim NL_ListCompteurRatio As Integer
Dim k As Integer
Dim TestExistence As Boolean
k = 1
N = 0
TestExistence = False
With Worksheets("Valeur")
If Not IsEmpty(C) Then
'Initialisation du tableau ListCompteurRatio avec la première valeur
If N = 0 Then
N = N + 1
ReDim Preserve ListCompteurRatio(N)
ListCompteurRatio(N).Ratio_C = .Cells(C.Row, C.Column + 1)
If .Cells(C.Row, C.Column + 2) = "" Then
ListCompteurRatio(N).Nom_C = "" & .Cells(C.Row, C.Column + 5) & "/" & .Cells(C.Row, C.Column + 6) & "/" & .Cells(C.Row, C.Column + 3) & ""
Else
ListCompteurRatio(N).Nom_C = .Cells(C.Row, C.Column + 2)
End If
Else
'Remplissage du tableau ListCompteurRatio
For k = LBound(ListCompteurRatio) To UBound(ListCompteurRatio)
'S'il n'y a pas de compteur indiv. avec les tableaux des compteurs électriques
If .Cells(C.Row, C.Column + 2) = "" Then
If "" & .Cells(C.Row, C.Column + 5) & "/" & .Cells(C.Row, C.Column + 6) & "/" & .Cells(C.Row, C.Column + 3) & "" = ListCompteurRatio(k).Nom_C Then
TestExistence = True
NL_ListCompteurRatio = k
Exit For:
End If
'S'il y a un compteur indiv.
Else
If .Cells(C.Row, C.Column + 2) = ListCompteurRatio(k).Nom_C Then
TestExistence = True
NL_ListCompteurRatio = k
Exit For:
End If
End If
Next k
If TestExistence = True Then
ListCompteurRatio(NL_ListCompteurRatio).Ratio_C = ListCompteurRatio(NL_ListCompteurRatio).Ratio_C + .Cells(C.Row, C.Column + 1)
Else
N = N + 1
ReDim Preserve ListCompteurRatio(N)
ListCompteurRatio(N).Ratio_C = .Cells(C.Row, C.Column + 1)
If .Cells(C.Row, C.Column + 2) = "" Then
ListCompteurRatio(N).Nom_C = "" & .Cells(C.Row, C.Column + 5) & "/" & .Cells(C.Row, C.Column + 6) & "/" & .Cells(C.Row, C.Column + 3) & ""
Else
ListCompteurRatio(N).Nom_C = .Cells(C.Row, C.Column + 2)
End If
End If
TestExistence = False
End If
End If
End With
A(1) = N
A(2) = ListCompteurRatio(N).Nom_C
A(3) = ListCompteurRatio(N).Ratio_C
ListeConsoElec = A
End Function |
Partager