Problème dans un comptage

Bonjour à tous,

J'ai essayé de trouver quelque chose de similaire à mon soucis mais sans succès.

Dans le fichier en pièce jointe, j'essaye d'avoir un tableau de bord qui compte les devis, commandes etc, qui sont toutes rentrées dans le même tableur excel.

La procédure fonctionnait plutôt bien mais j'ai remarqué que lorsque la dernière ligne rentrée était du type facturation, il semble que cette dernière ligne ne soit pas comptabiliser alors que je n'ai ^pas eu le soucis pour les entrées du type commande ou devis.

Le fichier est trop volumineux pour le mettre en pièce jointe, je vous met alors juste la partie du code qui semble poser problème

'***Déclaration et init des variables****
Dim maPlage As Range
Dim PlageAutofit As Range
Dim Dernligne As Long, DernColonne As Integer
Dim i As Integer

'***Compte RC****
Dim nbdevisRC As Integer
Dim nbdevisRCactif As Integer
Dim nbdevisRCwarn As Integer
Dim nbdevisrepRC As Integer
Dim nbdevisrepRCactif As Integer
Dim nbdevisrepRCwarn As Integer
Dim nbcommandeRC As Integer
Dim nbcommandeRCactif As Integer
Dim nbcommandeRCwarn As Integer
Dim nbcommanderepRC As Integer
Dim nbcommanderepRCactif As Integer
Dim nbcommanderepRCwarn As Integer
Dim nbfacturationRC As Integer
Dim ratiodevisRC As Currency
Dim ratiocommandeRC As Currency

nbdevisRC = 0
nbdevisRCwarn = 0
nbdevisrepRC = 0
nbdevisrepRCwarn = 0
nbcommandeRC = 0
nbcommandeRCwarn = 0
nbcommanderepRC = 0
nbcommanderepRCwarn = 0
nbfacturationRC = 0

'***Compte RSA****
Dim nbdevisRSA As Integer
Dim nbdevisRSAactif As Integer
Dim nbdevisRSAwarn As Integer
Dim nbdevisrepRSA As Integer
Dim nbdevisrepRSAactif As Integer
Dim nbdevisrepRSAwarn As Integer
Dim nbcommandeRSA As Integer
Dim nbcommandeRSAactif As Integer
Dim nbcommandeRSAwarn As Integer
Dim nbcommanderepRSA As Integer
Dim nbcommanderepRSAactif As Integer
Dim nbcommanderepRSAwarn As Integer
Dim nbfacturationRSA As Integer
Dim ratiodevisRSA As Currency
Dim ratiocommandeRSA As Currency

nbdevisRSA = 0
nbdevisRSAwarn = 0
nbdevisrepRSA = 0
nbdevisrepRSAwarn = 0
nbcommandeRSA = 0
nbcommandeRSAwarn = 0
nbcommanderepRSA = 0
nbcommanderepRSAwarn = 0
nbfacturationRSA = 0

'***Compte PSA****
Dim nbdevisPSA As Integer
Dim nbdevisPSAactif As Integer
Dim nbdevisPSAwarn As Integer
Dim nbdevisrepPSA As Integer
Dim nbdevisrepPSAactif As Integer
Dim nbdevisrepPSAwarn As Integer
Dim nbcommandePSA As Integer
Dim nbcommandePSAactif As Integer
Dim nbcommandePSAwarn As Integer
Dim nbcommanderepPSA As Integer
Dim nbcommanderepPSAactif As Integer
Dim nbcommanderepPSAwarn As Integer
Dim nbfacturationPSA As Integer
Dim ratiodevisPSA As Currency
Dim ratiocommandePSA As Currency

nbdevisPSA = 0
nbdevisPSAwarn = 0
nbdevisrepPSA = 0
nbdevisrepPSAwarn = 0
nbcommandePSA = 0
nbcommandePSAwarn = 0
nbcommanderepPSA = 0
nbcommanderepPSAwarn = 0
nbfacturationPSA = 0

'*** Variables gen****

Dim nbdevistotal As Integer
Dim nbdevistotalwarn As Integer
Dim nbdevisreptotal As Integer
Dim nbdevisreptotalwarn As Integer
Dim nbcommandetotal As Integer
Dim nbcommandetotalwarn As Integer
Dim nbcommandereptotal As Integer
Dim nbcommandereptotalwarn As Integer
Dim nbfacturationtotal As Integer

nbdevistotal = 0
nbdevistotalwarn = 0
nbdevisreptotal = 0
nbdevisreptotalwarn = 0
nbcommandetotal = 0
nbcommandetotalwarn = 0
nbcommandereptotal = 0
nbcommandereptotalwarn = 0
nbfacturationtotal = 0

Dim nbincomplet As Integer
Dim Dernlignedata As Integer
Dim idata As Integer
Dim Plagedata As Range
Dim cel As Range
Dim Today As Date

'****suppression des éventuels filtres pour le comptage****
If Worksheets(1).AutoFilterMode = True Then                  'Test si filtre est activé
   Worksheets(1).AutoFilterMode = False                     'Si oui désactivation
End If

'****Détection dernière ligne non vide****
Dernligne = Range("A" & Rows.Count).End(xlUp).Row

'****Comptage global****

For i = 2 To Dernligne

'****Devis RC****
If Cells(i, 2) = "RC" And Cells(i, 5) = "Devis" Then
nbdevisRC = nbdevisRC + 1
    If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
    nbdevisRCactif = nbdevisRCactif + 1
        If Now() > Cells(i, 8) Then
        nbdevisRCwarn = nbdevisRCwarn + 1
        End If
    End If

    '****Devis Réparation RC****
    ElseIf Cells(i, 2) = "RC" And Cells(i, 5) = "Devis Rep" Then
    nbdevisrepRC = nbdevisrepRC + 1
        If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
        nbdevisrepRCactif = nbdevisrepRCactif + 1
            If Now() > Cells(i, 8) Then
            nbdevisrepRCwarn = nbdevisrepRCwarn + 1
            End If
        End If

        '****Commandes RC****
        ElseIf Cells(i, 2) = "RC" And Cells(i, 5) = "Commande" Then
        nbcommandeRC = nbcommandeRC + 1
        If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
        nbcommandeRCactif = nbcommandeRCactif + 1
            If Now() > Cells(i, 8) Then
            nbcommandeRCwarn = nbcommandeRCwarn + 1
            End If
        End If

                    '****Commandes réparation RC****
            ElseIf Cells(i, 2) = "RC" And Cells(i, 5) = "Commande Rep" Then
            nbcommanderepRC = nbcommanderepRC + 1
            If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
            nbcommanderepRCactif = nbcommanderepRCactif + 1
                If Now() > Cells(i, 8) Then
                nbcommanderepRCwarn = nbcommanderepRCwarn + 1
                End If
            End If

                                  '****Facturation RC****
                ElseIf Cells(i, 2) = "RC" And Cells(i, 5) = "Facturation" Then
                nbfacturationRC = nbfacturationRC + 1

'****Devis RSA****
ElseIf Cells(i, 2) = "RSA" And Cells(i, 5) = "Devis" Then
nbdevisRSA = nbdevisRSA + 1
If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
nbdevisRSAactif = nbdevisRSAactif + 1
    If Now() > Cells(i, 8) Then
    nbdevisRSAwarn = nbdevisRSAwarn + 1
    End If
End If

    '****Devis Réparation RSA****
    ElseIf Cells(i, 2) = "RSA" And Cells(i, 5) = "Devis Rep" Then
    nbdevisrepRSA = nbdevisrepRSA + 1
    If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
    nbdevisrepRSAactif = nbdevisrepRSAactif + 1
        If Now() > Cells(i, 8) Then
        nbdevisrepRSAwarn = nbdevisrepRSAwarn + 1
        End If
    End If

        '****Commandes RSA****
        ElseIf Cells(i, 2) = "RSA" And Cells(i, 5) = "Commande" Then
        nbcommandeRSA = nbcommandeRSA + 1
        If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
        nbcommandeRSAactif = nbcommandeRSAactif + 1
            If Now() > Cells(i, 8) Then
            nbcommandeRSAwarn = nbcommandeRSAwarn + 1
            End If
        End If

            '****Commandes réparation RSA****
            ElseIf Cells(i, 2) = "RSA" And Cells(i, 5) = "Commande Rep" Then
            nbcommanderepRSA = nbcommanderepRSA + 1
            If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
            nbcommanderepRSAactif = nbcommanderepRSAactif + 1
                If Now() > Cells(i, 8) Then
                nbcommanderepRSAwarn = nbcommanderepRSAwarn + 1
                End If
            End If

                                              '****Facturation RSA****
                ElseIf Cells(i, 2) = "RSA" And Cells(i, 5) = "Facturation" Then
                nbfacturationRSA = nbfacturationRSA + 1

'****Devis PSA****
ElseIf Cells(i, 2) = "PSA" And Cells(i, 5) = "Devis" Then
nbdevisPSA = nbdevisPSA + 1
If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
nbdevisPSAactif = nbdevisPSAactif + 1
    If Now() > Cells(i, 8) Then
    nbdevisPSAwarn = nbdevisPSAwarn + 1
    End If
End If

    '****Devis Réparation PSA****
    ElseIf Cells(i, 2) = "PSA" And Cells(i, 5) = "Devis Rep" Then
    nbdevisrepPSA = nbdevisrepPSA + 1
    If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
    nbdevisrepPSAactif = nbdevisrepPSAactif + 1
        If Now() > Cells(i, 8) Then
        nbdevisrepPSAwarn = nbdevisrepPSAwarn + 1
        End If
    End If

        '****Commandes PSA****
        ElseIf Cells(i, 2) = "PSA" And Cells(i, 5) = "Commande" Then
        nbcommandePSA = nbcommandePSA + 1
        If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
        nbcommandePSAactif = nbcommandePSAactif + 1
            If Now() > Cells(i, 8) Then
            nbcommandePSAwarn = nbcommandePSAwarn + 1
            End If
        End If

            '****Commandes réparation PSA****
            ElseIf Cells(i, 2) = "PSA" And Cells(i, 5) = "Commande Rep" Then
            nbcommanderepPSA = nbcommanderepPSA + 1
            If Cells(i, 13) = "En cours" Or Cells(i, 13) = "Actif" Then
            nbcommanderepPSAactif = nbcommanderepPSAactif + 1
                If Now() > Cells(i, 8) Then
                nbcommanderepPSAwarn = nbcommanderepPSAwarn + 1
                End If
            End If

                                              '****Facturation PSA****
                ElseIf Cells(i, 2) = "PSA" And Cells(i, 5) = "Facturation" Then
                nbfacturationPSA = nbfacturationPSA + 1

                        Else: nbincomplet = nbincomplet + 1

End If
Next

Si quelqu'un à une idée, je suis preneur!

Merci d'avance.

Merci d'avance.

Bonjour

Il existe au dessus du message que tu tapes une balise "Code" rendant le code plus attractif et clair. Merci de l'utiliser. (C'est fait pour ton message)

Sans fichier, je crains que tes chances d'avoir une réponse soient réduites. Ne peux tu le compresser ou l'envoyer avec Cjoint.com?

Cordialement

Bonjour,

Avant de faire du codage complexe, tu peux essayer un TCD.

Mais pour t'aider, Amadéus a raison, un fichier est nécessaire, même partiel.

Rechercher des sujets similaires à "probleme comptage"