Excel Erreur d'execution 1004
Résolu
Franzoi3
-
michel_m Messages postés 16602 Date d'inscription Statut Contributeur Dernière intervention -
michel_m Messages postés 16602 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
J'ai un problème d'execution sur une macro VBA.
Quand j'execute pas à pas tout fonctionne normalement mais si je fais une execution normale, l'erreur apparait.
Voici une partie de mon code :
For q = 0 To DureeAO - 1
While Sheets("Planing").Cells(19, j + p + q) <> ""
p = p + 1
Wend
Set comm = Sheets("Planing").Cells(n, j + q + p)
comm.AddComment
comm.Comment.Visible = False
comm.Comment.Text Text:=ville
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10066431
End With
Next
Le problème provient de l'ajout du commentaire. j'ai essayer de le passer en Range mais ça ne marche pas non plus/.
Pourriez-vous m'éclaire svp.
Merci d'avance
J'ai un problème d'execution sur une macro VBA.
Quand j'execute pas à pas tout fonctionne normalement mais si je fais une execution normale, l'erreur apparait.
Voici une partie de mon code :
For q = 0 To DureeAO - 1
While Sheets("Planing").Cells(19, j + p + q) <> ""
p = p + 1
Wend
Set comm = Sheets("Planing").Cells(n, j + q + p)
comm.AddComment
comm.Comment.Visible = False
comm.Comment.Text Text:=ville
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10066431
End With
Next
Le problème provient de l'ajout du commentaire. j'ai essayer de le passer en Range mais ça ne marche pas non plus/.
Pourriez-vous m'éclaire svp.
Merci d'avance
A voir également:
- 0x80070643
- Liste déroulante excel - Guide
- Word et excel gratuit - Guide
- Déplacer colonne excel - Guide
- Si ou excel - Guide
- Excel moyenne - Guide
3 réponses
Bonjour
lorsque tu as une erreur indique la ligne fautive : cela simplifie le boulot
et tu as intér^t (pour faciliter la maintenance) d'écrire avant comm.addcomment
comm.clearcomments et de grouper les propriétés et/ou mméthodes dans un "bloc " (With... End with)
code optimisé
Michel
lorsque tu as une erreur indique la ligne fautive : cela simplifie le boulot
comm.AddComment comm.Comment.Visible = False comm.Comment.Text Text:=ville With comm.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 10066431 End With
et tu as intér^t (pour faciliter la maintenance) d'écrire avant comm.addcomment
comm.clearcomments et de grouper les propriétés et/ou mméthodes dans un "bloc " (With... End with)
code optimisé
With comm .ClearComments .AddComment .Comment.Visible = False .Comment.Text Text:=ville .Interior.Color = 10066431 End With
Michel
Bonjour,
Set comm = Sheets("Planing").Cells(n, j + q + p)
n est defini ou? parce que si n=0 alors erreur 1004
Bonne suite
Set comm = Sheets("Planing").Cells(n, j + q + p)
n est defini ou? parce que si n=0 alors erreur 1004
Bonne suite
Bonjour,
Merci de t'interesser à mon pb.
n est toujours superieur à 0.
voilà mon code en entier
Sub test()
Range("B7:XFD10").Select
Range("B7:XFD10").Clear
Range("C5").Select
i = 5
While Sheets("Travail").Cells(i, 2) <> ""
DateIni = Sheets("Travail").Cells(i, 3)
DureeAO = Sheets("Travail").Cells(i, 5) * 2
ville = Sheets("Travail").Cells(i, 2)
For j = 2 To 16000
DatePlaning = Sheets("Planing").Cells(3, j)
If DatePlaning = DateIni Then
l = 0
For k = j To DureeAO + j
If Sheets("Planing").Cells(19, k + l) <> "" Then
l = l + 1
k = k - 1
End If
Next
'Dim TabDate() As Tabs
'ReDim TabDate(DureeCom + l)
n = 7
For m = j To DureeAO + j + l
If Sheets("Planing").Cells(n, m) <> "" Then
n = n + 1
End If
Next
p = 0
For q = 0 To DureeAO - 1
While Sheets("Planing").Cells(19, j + p + q) <> ""
p = p + 1
Wend
Set comm = Sheets("Planing").Cells(n, j + q + p)
comm.AddComment
comm.Comment.Visible = False
comm.Comment.Text Text:=ville
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10066431
End With
Next
Exit For
End If
Next
i = i + 1
Wend
End Sub
Je ne comprend vraiment pas pourquoi il ne marche pas.
Merci de t'interesser à mon pb.
n est toujours superieur à 0.
voilà mon code en entier
Sub test()
Range("B7:XFD10").Select
Range("B7:XFD10").Clear
Range("C5").Select
i = 5
While Sheets("Travail").Cells(i, 2) <> ""
DateIni = Sheets("Travail").Cells(i, 3)
DureeAO = Sheets("Travail").Cells(i, 5) * 2
ville = Sheets("Travail").Cells(i, 2)
For j = 2 To 16000
DatePlaning = Sheets("Planing").Cells(3, j)
If DatePlaning = DateIni Then
l = 0
For k = j To DureeAO + j
If Sheets("Planing").Cells(19, k + l) <> "" Then
l = l + 1
k = k - 1
End If
Next
'Dim TabDate() As Tabs
'ReDim TabDate(DureeCom + l)
n = 7
For m = j To DureeAO + j + l
If Sheets("Planing").Cells(n, m) <> "" Then
n = n + 1
End If
Next
p = 0
For q = 0 To DureeAO - 1
While Sheets("Planing").Cells(19, j + p + q) <> ""
p = p + 1
Wend
Set comm = Sheets("Planing").Cells(n, j + q + p)
comm.AddComment
comm.Comment.Visible = False
comm.Comment.Text Text:=ville
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10066431
End With
Next
Exit For
End If
Next
i = i + 1
Wend
End Sub
Je ne comprend vraiment pas pourquoi il ne marche pas.
merci pour lui
pat'kwa :o)
mais j'ai l'impression qu'il se fout pas de ce que je lui ai proposé
je passe en résolu