Il ne rentre pas dans ma macro

Quelqu'un peux m'aider SVP
J'ai écris la macro suivante, mais elle ne rentre pas dedans même si les deux valeur sont identique pourqu'oi. je vous ai joint la macro complète

If FPresence.Cells(3, 23) = FServiceEtage.Cells(2, VarColonne) Then

mais si je remplace VarColonne par une colonne fixe ça marche impeccable.

Private Sub CommandButton1_Click()
Dim VarNbGard As Byte
Dim VarColonne As Integer
Dim i As Integer
Dim j As Integer
Dim L As Integer
VarNbGard = FBrigade.Cells(14, 2)

For VarColonne = 2 To 54

'If FPresence.Cells(3, 23) = FServiceEtage.Cells(2, 33) Then
If FPresence.Cells(3, 23) = FServiceEtage.Cells(2, VarColonne) Then

For i = 3 To FServiceEtage.Cells(1, 1) + 2 'On parcour le classeur Service Etage
For j = 15 To VarNbGard + 14 'On parcour les présences

If FPresence.Cells(j, 4) + FPresence.Cells(j, 5) = FServiceEtage.Cells(i, 2) + FServiceEtage.Cells(i, 3) Then
' FPresence.Cells(j, 9) = FServiceEtage.Cells(i, 33) 'Service Etage
FPresence.Cells(j, 9) = FServiceEtage.Cells(i, VarColonne) 'Service Etage

' j = 15
'i = i + 1
End If
' i = i + 1

Next

Next

End If

VarColonne = VarColonne + 1

Next

End Sub

MERCI D'AVANCE DE VOTRE AIDE

1 réponse

  1. Bonjour,

    FPresence et FServiceEtage sont definies ou ???????
    0
    1. Se sont les noms de mes onglets ou je vais travailler deçu
      0
    2. @viret1290Re,

      au plus simple, car je ne sais pas comment sont organisees vos donnees:

      Private Sub CommandButton1_Click()
          Dim VarNbGard As Byte
          Dim VarColonne As Integer
          Dim i As Integer
          Dim j As Integer
          Dim L As Integer
          
          VarNbGard = Worksheets("FBrigade").Cells(14, 2)
          For VarColonne = 2 To 54
              If Worksheets("FPresence").Cells(3, 23) = Worksheets("FServiceEtage").Cells(2, VarColonne) Then
                  For i = 3 To Worksheets("FServiceEtage").Cells(1, 1) + 2 'On parcour le classeur Service Etage
                      For j = 15 To VarNbGard + 14 'On parcour les présences
                          If Worksheets("FPresence").Cells(j, 4) + Worksheets("FPresence").Cells(j, 5) = Worksheets("FServiceEtage").Cells(i, 2) + Worksheets("FServiceEtage").Cells(i, 3) Then
                              Worksheets("FPresence").Cells(j, 9) = Worksheets("FServiceEtage").Cells(i, VarColonne) 'Service Etage
                          End If
                      Next j
                  Next i
              End If
          Next VarColonne
      End Sub
      0
    3. merci beaucoup pour votre réponse
      0