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 68 69 70 71 72
| While Not EOF(intFic)
'lire la ligne et la stocker dans strligne
lblprogress.Caption = "Lecture de la ligne " + CStr(Nbreligne) + " sur " + CStr(NombreDeLignes)
Line Input #intFic, strLigne
' si la ligne commence par BA. , c'est la ligne qui contient nos données
If InStr(1, strLigne, "BA.") Then
'puisque la ligne contient beacoup d'info elle doit etre stockée dnas un tableau délimité par espace
Do While InStr(1, strLigne, " ") > 0
strLigne = Replace(strLigne, " ", " ")
Loop
Dim ligneEntiere As Variant
'Diviser la ligne séparée par tabulation
ligneEntiere = Split(strLigne, " ")
'variable qui contiendera le numéro de compte
Dim NumeroDeCompte As Variant
'Diviser la ligne séparée par .
NumeroDeCompte = Split(ligneEntiere(1), ".")
'ecriture du compte dans la cellule A2 , A3 , A4 et ainsi de suite
Dim MontantApresVirgule As Variant
Dim MontantAvantVirgule As Variant
Dim Montant As Variant
Montant = ligneEntiere(UBound(ligneEntiere))
Dim PosDerniereVirguleMontant As Integer
PosDerniereVirguleMontant = InStrRev(Montant, ".")
If PosDerniereVirguleMontant = 0 Then
Montant = Montant
Else
MontantApresVirgule = Mid(Montant, PosDerniereVirguleMontant + 1, 2)
MontantAvantVirgule = Mid(Montant, 1, PosDerniereVirguleMontant - 1)
MontantAvantVirgule = Replace(MontantAvantVirgule, ",", "")
MontantAvantVirgule = Replace(MontantAvantVirgule, " ", "")
Montant = MontantAvantVirgule & "," & MontantApresVirgule
End If
Dim Rubrique As String
Rubrique = Mid(NumeroDeCompte(1), 1, 4)
'ActiveWorkbook.ActiveSheet.range("B" & i).Value = CDbl(Montant)
If NumeroDeCompte(1) = TableauFinalParCompteMoyen(j, 0) Or TableauFinalParCompteMoyen(j, 0) = "" Then
TableauFinalParCompteMoyen(j, 0) = NumeroDeCompte(1)
TableauFinalParCompteMoyen(j, 1) = CDbl(TableauFinalParCompteMoyen(j, 1)) + CDbl(Montant)
Else
j = j + 1
'ReDim Preserve TableauFinalParCompte(0 To j, 0 To 2)
TableauFinalParCompteMoyen(j, 0) = NumeroDeCompte(1)
TableauFinalParCompteMoyen(j, 1) = CDbl(Montant)
End If
If Rubrique = TableauFinalParRubriqueMoyen(k, 0) Or TableauFinalParRubriqueMoyen(k, 0) = "" Then
TableauFinalParRubriqueMoyen(k, 0) = Rubrique
TableauFinalParRubriqueMoyen(k, 1) = CDbl(TableauFinalParRubriqueMoyen(k, 1)) + CDbl(Montant)
Else
k = k + 1
'ReDim Preserve TableauFinalParCompte(0 To j, 0 To 2)
TableauFinalParRubriqueMoyen(k, 0) = Rubrique
TableauFinalParRubriqueMoyen(k, 1) = CDbl(Montant)
End If
i = i + 1
End If
'pas d'importance
Me.Repaint |
Partager