[EXCEL - VBA] Err d'exec 9 : l'indice n'app..
Résolu/Fermé
artamys
Messages postés
120
Date d'inscription
lundi 18 juin 2007
Statut
Membre
Dernière intervention
9 mars 2018
-
10 juil. 2012 à 16:51
artamys Messages postés 120 Date d'inscription lundi 18 juin 2007 Statut Membre Dernière intervention 9 mars 2018 - 10 juil. 2012 à 18:17
artamys Messages postés 120 Date d'inscription lundi 18 juin 2007 Statut Membre Dernière intervention 9 mars 2018 - 10 juil. 2012 à 18:17
A voir également:
- [EXCEL - VBA] Err d'exec 9 : l'indice n'app..
- Liste déroulante excel - Guide
- Formule excel - Guide
- Si et excel - Guide
- Aller à la ligne excel - Guide
- Mise en forme conditionnelle excel - Guide
3 réponses
eriiic
Messages postés
24570
Date d'inscription
mardi 11 septembre 2007
Statut
Contributeur
Dernière intervention
23 avril 2024
7 213
10 juil. 2012 à 17:10
10 juil. 2012 à 17:10
Bonjour,
tu pourrais préparer 2 fichiers exemple et les déposer sur cjoint.com
Coller ici le lien fourni.
eric
tu pourrais préparer 2 fichiers exemple et les déposer sur cjoint.com
Coller ici le lien fourni.
eric
pijaku
Messages postés
12263
Date d'inscription
jeudi 15 mai 2008
Statut
Modérateur
Dernière intervention
4 janvier 2024
2 744
Modifié par pijaku le 10/07/2012 à 17:11
Modifié par pijaku le 10/07/2012 à 17:11
Bonjour,
Pour éviter ces problèmes "d'indice n'appartient pas à la sélection", tu peux utiliser des blocs With End With.
Exemple "àlacon" :
A noter l'utilisation des points .Sheets(machin) point = qui se réfère à l'objet du bloc With...
Cordialement,
Franck P
Pour éviter ces problèmes "d'indice n'appartient pas à la sélection", tu peux utiliser des blocs With End With.
Exemple "àlacon" :
With WorkBooks("Classeur1.xls") If .Sheets("Feuil1").Range("A1") = "Poireau" Then .Sheets("Feuil2").Range("A2") = "Rien" End If End With With WorkBooks("Classeur2.xls") If WorkBooks("Classeur1.xls").Sheets("Feuil1").Range("A1") = "Poireau" Then .Sheets("Feuil2").Range("A2") = "Rien" End If End With
A noter l'utilisation des points .Sheets(machin) point = qui se réfère à l'objet du bloc With...
Cordialement,
Franck P
artamys
Messages postés
120
Date d'inscription
lundi 18 juin 2007
Statut
Membre
Dernière intervention
9 mars 2018
7
10 juil. 2012 à 18:17
10 juil. 2012 à 18:17
Super merci, je venais juste de me bidouiller une solution en concatenant les résultat dans une variable : séparé avec un "/" que je converti ensuite.
Je vais mettre en place votre méthode plus propre.
Merci beaucoup Eric et Franck.
Sub Recupdate3(m)
Dim Nom_Maitre2 As String
Dim Nom_Esclave2 As String
Sheets("Liste_2").Select
Nom_Maitre2 = ActiveWorkbook.Name
Nom_Esclave2 = Sheets("Liste_2").Cells(m, 3).Value
Workbooks.Open (Sheets("Liste_2").Cells(m, 2).Value)
Application.DisplayAlerts = False
Workbooks(Nom_Esclave2).Activate
ligne = 0
B = 0
A = 0
X = Sheets("SAISIE V9").Range("F3")
y = Sheets("SAISIE V9").Range("F4")
Z = Sheets("SAISIE V9").Range("A3")
For o = 1 To 1000
If Sheets("SAISIE V9").Range("E" & o) = "TTC" Then A = Sheets("SAISIE V9").Range("D" & o)
If Sheets("SAISIE V9").Range("E" & o) = "TTC" Then B = B & "/" & A
Next o
Application.DisplayAlerts = False
Workbooks(Nom_Esclave2).Close (False)
Application.DisplayAlerts = False
Workbooks(Nom_Maitre2).Activate
Sheets("Liste_2").Cells(m, 7).Value = X
Sheets("Liste_2").Cells(m, 8).Value = y
Sheets("Liste_2").Cells(m, 9).Value = Z
Sheets("Liste_2").Cells(m, 10).Value = B
Je vais mettre en place votre méthode plus propre.
Merci beaucoup Eric et Franck.
Sub Recupdate3(m)
Dim Nom_Maitre2 As String
Dim Nom_Esclave2 As String
Sheets("Liste_2").Select
Nom_Maitre2 = ActiveWorkbook.Name
Nom_Esclave2 = Sheets("Liste_2").Cells(m, 3).Value
Workbooks.Open (Sheets("Liste_2").Cells(m, 2).Value)
Application.DisplayAlerts = False
Workbooks(Nom_Esclave2).Activate
ligne = 0
B = 0
A = 0
X = Sheets("SAISIE V9").Range("F3")
y = Sheets("SAISIE V9").Range("F4")
Z = Sheets("SAISIE V9").Range("A3")
For o = 1 To 1000
If Sheets("SAISIE V9").Range("E" & o) = "TTC" Then A = Sheets("SAISIE V9").Range("D" & o)
If Sheets("SAISIE V9").Range("E" & o) = "TTC" Then B = B & "/" & A
Next o
Application.DisplayAlerts = False
Workbooks(Nom_Esclave2).Close (False)
Application.DisplayAlerts = False
Workbooks(Nom_Maitre2).Activate
Sheets("Liste_2").Cells(m, 7).Value = X
Sheets("Liste_2").Cells(m, 8).Value = y
Sheets("Liste_2").Cells(m, 9).Value = Z
Sheets("Liste_2").Cells(m, 10).Value = B