L'indice ne correspond pas à la selection

Résolu
Bonjour,

Voila:

Private Sub CommandButton2_Click()
For i = 1 To 6
If Sheets("INFORMATIONS").Cells(18, 4).Text = Sheets("Grande").Cells(16, i).Value Then
Sheets("Grande").Cells(17, i).Value = Sheets("INFORMATIONS").Cells(18, 5).Value
End If
Next
End Sub


"L'indice ne correspond pas à la selection" en surlignant :
"If Sheets("INFORMATIONS").Cells(18, 4).Text = Sheets("Grande").Cells(16, i).Value Then"

je ne comprend pas pourquoi....

Ctesias,

3 réponses

  • Votes
  • Date
  • Date décroissante
  1. Contributeur
    Bonjour,

    tu as essayé en remplaçant Cells(18, 4).Text par Cells(18, 4).Value ?
    Il me semble que cela peut régler le problème.
    1. Yep, c'etait le premier truc que j'avais essayé,mais ca ne regle pas le probleme :s
      1. Modérateur
        Bonjour,
        Essaye ceci d'abord :
        Private Sub CommandButton2_Click()
        Dim Chaine As String, Result As String
        
        With Sheets("INFORMATIONS")
            Chaine = .Cells(18, 4).Text
            Result = .Cells(18, 5).Value
        End With
        For i = 1 To 6
        With Sheets("Grande")
            If .Cells(16, i).Value = Chaine Then
                .Cells(17, i).Value = Result
            End If
        End With
        Next
        End Sub

        A toi d'adapter Result As ... type de variable adéquat.
    2. probleme resolu....

      C'ets tout bete, mais je ne comprend pas pourquoi Sheets("INFORMATIONS") ne marche pas, mais actvieszheet marche...