nobilis
Messages postés32Date d'inscriptionvendredi 11 février 2005StatutMembreDernière intervention21 mars 2005
-
17 mars 2005 à 15:25
cs_CanisLupus
Messages postés3757Date d'inscriptionmardi 23 septembre 2003StatutMembreDernière intervention13 mars 2006
-
18 mars 2005 à 17:23
Bonjour,
J'ai créé une macro excel qui me permettait de reprendre les informations (nom du sujet, journaliste et technicien) d'un tableau principal pour les placer dans deux tableaux (JT et JT+). Donc, le nom du sujet (reportage) était associé à un journaliste et à un technicien.
J'ai testé la macro plusieurs fois et tout semblait très bien fonctionner. Mais maintenant, j'ai l'erreur suivante qui apparaît : "erreur d'exécution '9' l'indice n'appartient pas à la sélection.
Pq est-ce que ça ne fonctionne plus alors que tout fonctionait très bien ?
Merci
'Si Calendrier JT/JT+ associée à un "JT", remplir
'les champs de JT dans tableau des Sujets JT
Dim tabCol(50), x, y As Integer
'Réinitialisation du tableau
For x = 0 To 50
tabCol(x) = 0
Next
y = 0 'Première cellule du tableau
j = 650 'Première ligne du tableau JT
For i = 8 To 474 Step 8
'Remplissage du tabCol avec les n° de colonnes remplies
For x = 3 To 26 If Cells(i + 1, x) <> "" Or Cells(i + 2, x) <> "" Then tabCol(y) x: y y + 1
Next x
If Cells(i + 7, 3).Value "JT" Or Cells(i + 7, 4).Value "JT" Or Cells(i + 7, 5).Value = "JT" Or Cells(i + 7, 6).Value = "JT" Or Cells(i + 7, 7).Value = "JT" Or Cells(i + 7, 8).Value = "JT" Or Cells(i + 7, 9).Value = "JT" Or Cells(i + 7, 10).Value = "JT" Or Cells(i + 7, 11).Value = "JT" Or Cells(i + 7, 12).Value = "JT" Or Cells(i + 7, 13).Value = "JT" Or Cells(i + 7, 14).Value = "JT" Or Cells(i + 7, 15).Value = "JT" Or Cells(i + 7, 16).Value = "JT" Or Cells(i + 7, 17).Value = "JT" Or Cells(i + 7, 18).Value = "JT" Or Cells(i + 7, 19).Value = "JT" Or Cells(i + 7, 20).Value = "JT" Or Cells(i + 7, 21).Value = "JT" Or Cells(i + 7, 22).Value = "JT" Or Cells(i + 7, 23).Value = "JT" Or Cells(i + 7, 24).Value = "JT" Or Cells(i + 7, 25).Value = "JT" Or Cells(i + 7, 26).Value = "JT" Then
Cells(j, 1).Value = "Sujet " & j - 649
Cells(j, 3).Value = Cells(i + 1, 1).Value & " - Journaliste : " & Cells(i + 1, tabCol((i - 8) / 8)).Value & " , Technicien : " & Cells(i + 2, tabCol((i - 8) / 8)).Value
Else: j = j - 1
End If
j = j + 1 'Passer à la ligne suivante du tableau JT
cs_CanisLupus
Messages postés3757Date d'inscriptionmardi 23 septembre 2003StatutMembreDernière intervention13 mars 200620 17 mars 2005 à 20:16
Salut,
C'est normal, tu dimensionnes ton tableau tabCol à 50 et ta boucle va de 8 à 474.
Plus loin il y tabCol((i - 8) / 8).
Pour une valeur de i = 474 ça donne par ex : tabCol(58.25).
Déjà, ça dépasse 50 et surtout, l'indice ne peut accepter des décimales.
nobilis
Messages postés32Date d'inscriptionvendredi 11 février 2005StatutMembreDernière intervention21 mars 20051 18 mars 2005 à 09:32
Grand merci Loup Gris
1) J'ai modifié ma ligne "For i = 8 to 474 Step 8" en "For i=8 to 400 Step 8" (c'est déjà mieux ;-) )
2) Pour la variable lig que tu me proposes d'intégrer, ma variable y, ne joue-t-elle pas le même rôle ? (voir ci-dessous)
3) Le problème survient déjà à la ligne :"If Cells(i + 1, x) <> "" Or Cells(i + 2, x) <> "" Then tabCol(y) x: y y + 1"
et précisément à "tabCol(y) = x"
-------------------------
Dim tabCol(50), x, y As Integer
'Réinitialisation du tableau
For x = 0 To 50
tabCol(x) = 0
Next
y = 0 'Première cellule du tableau
j = 650 'Première ligne du tableau JT
For i = 8 To 400 Step 8
'Remplissage du tabCol avec les n° de colonnes remplies
For x = 3 To 26 If Cells(i + 1, x) <> "" Or Cells(i + 2, x) <> "" Then tabCol(y) x: y y + 1
Next x
If Cells(i + 7, 3).Value "JT" Or Cells(i + 7, 4).Value "JT" Or Cells(i + 7, 5).Value = "JT" Or Cells(i + 7, 6).Value = "JT" Or Cells(i + 7, 7).Value = "JT" Or Cells(i + 7, 8).Value = "JT" Or Cells(i + 7, 9).Value = "JT" Or Cells(i + 7, 10).Value = "JT" Or Cells(i + 7, 11).Value = "JT" Or Cells(i + 7, 12).Value = "JT" Or Cells(i + 7, 13).Value = "JT" Or Cells(i + 7, 14).Value = "JT" Or Cells(i + 7, 15).Value = "JT" Or Cells(i + 7, 16).Value = "JT" Or Cells(i + 7, 17).Value = "JT" Or Cells(i + 7, 18).Value = "JT" Or Cells(i + 7, 19).Value = "JT" Or Cells(i + 7, 20).Value = "JT" Or Cells(i + 7, 21).Value = "JT" Or Cells(i + 7, 22).Value = "JT" Or Cells(i + 7, 23).Value = "JT" Or Cells(i + 7, 24).Value = "JT" Or Cells(i + 7, 25).Value = "JT" Or Cells(i + 7, 26).Value = "JT" Then
Cells(j, 1).Value = "Sujet " & j - 649
Cells(j, 3).Value = Cells(i + 1, 1).Value & " - Journaliste : " & Cells(i + 1, tabCol((i - 8) / 8)).Value & " , Technicien : " & Cells(i + 2, tabCol((i - 8) / 8)).Value
Else: j = j - 1
End If
j = j + 1 'Passer à la ligne suivante du tableau JT