L'indice ne correspond pas à la selection

Résolu/Fermé
Ctesias Messages postés 724 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 1 décembre 2011 - 24 juin 2011 à 09:51
Ctesias Messages postés 724 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 1 décembre 2011 - 24 juin 2011 à 10:10
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

-nicolas- Messages postés 4173 Date d'inscription mercredi 5 mars 2008 Statut Contributeur Dernière intervention 5 septembre 2017 1 309
24 juin 2011 à 09:59
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.
0
Ctesias Messages postés 724 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 1 décembre 2011 36
24 juin 2011 à 10:01
Yep, c'etait le premier truc que j'avais essayé,mais ca ne regle pas le probleme :s
0
pijaku Messages postés 12263 Date d'inscription jeudi 15 mai 2008 Statut Modérateur Dernière intervention 4 janvier 2024 2 744
24 juin 2011 à 10:07
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.
0
Ctesias Messages postés 724 Date d'inscription lundi 16 mai 2011 Statut Membre Dernière intervention 1 décembre 2011 36
24 juin 2011 à 10:10
probleme resolu....

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