Boucle If (Problème incémentation)

Bonjour à tous,

je suis coincé sur la manipulation suivante :

Je souhaite stocker dans une variable le nombre de lignes dont la valeur en J est "CN" et afficher la somme dans la colonne Z

J'ai commencé le programme mais je suis bloqué :

Sub Compte()
    Dim i As Integer
    Dim Value As Integer

    Range("Z5:Z3000").ClearContents
    Value = 0
    Range("J5").Select
    With ThisWorkbook.Sheets("MDR_Compte")
        For i = .Range("J" & .Rows.Count).End(xlUp).Row To 2 Step -1
            If .Range("J" & i).Value = "CN" Then
              ActiveCell.Offset(0, 16) = "1"
              Value = Value + 1
            End If
        Next i
    End With
End Sub

Merci pour votre aide à tous

6mdr-comptage.xlsm (164.88 Ko)

HELP HELP

Avez-vous une piste ?

Merci

bonjour,

solution sur base de ce que j'ai compris

Sub Compte()
    Dim i As Integer
    Dim Value As Integer

    Range("Z5:Z3000").ClearContents
    Value = 0
    Range("J5").Select
    With ThisWorkbook.Sheets("MDR_Compte")
        For i = 2 To .Range("J" & .Rows.Count).End(xlUp).Row
            If .Range("J" & i).Value = "CN" Then
            Value = Value + 1
              .Range("J" & i).Offset(0, 16) = Value

            End If
        Next i
    End With
End Sub

C'est parfait,

Merci bcp

Rechercher des sujets similaires à "boucle probleme incementation"