Erreur 1004!
tinyspot0103
Messages postés
6
Statut
Membre
-
gbinforme Messages postés 14930 Date d'inscription Statut Contributeur Dernière intervention -
gbinforme Messages postés 14930 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour à tous,
J'ai eu un pb sur la macro de folie, c'était pas moi qui l'ai développée. Elle marchait avant, mais c"était toujours 1 fois sur 5, or cete fois elle marche pas du tout!!!
Elle se bloque toujours sur : ActiveCell.Offset(1, 0).Select
La macro est :
Sub synthesesite()
'
'
If MsgBox("LA MISE A JOUR DURE 2 MINUTES. VOULEZ VOUS CONTINUER ?", vbQuestion + vbYesNo, "MISE A JOUR DES DONNEES") = vbYes Then
Application.ScreenUpdating = False
Sheets("RECAP").Select
Range("$A$7:$DK$7").AutoFilter
Range("$A$7:$DK$7").AutoFilter
Sheets("SYNTHESE PAR SITE").Select
a = Range("b7").Value
b = Range("C7").Value
c = Range("D7").Value
d = Range("F6").Value
e = Range("J7").Value
f = Range("K7").Value
g = Range("L7").Value
h = Range("P7").Value
i = Range("q7").Value
j = Range("R7").Value
k = Range("E6").Value
Range("A8").Select
Do While ActiveCell.Offset(-1, 0).Value <> "CENTRALE + MAGASINS"
If ActiveCell.Value <> "" Then
Selection.Copy
Sheets("RECAP").Select
Range("E5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("7:7").Select
Selection.Find(What:=a, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couvmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=b, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couvpreviousmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=c, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couvpreviousyear = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=d, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
stock12m = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=k, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couv12m = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=e, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
VSmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=f, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
VSpreviousmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=g, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
VSpreviousyear = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=h, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
vtemonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=i, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
vtepreviousmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=j, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
vtepreviousyear = ActiveCell.Offset(-2, 0).Value
'''''
Sheets("SYNTHESE PAR SITE").Select
ActiveCell.Offset(0, 1).Value = couvmonth
ActiveCell.Offset(0, 2).Value = couvpreviousmonth
ActiveCell.Offset(0, 3).Value = couvpreviousyear
ActiveCell.Offset(0, 4).Value = couv12m
ActiveCell.Offset(0, 5).Value = stock12m
ActiveCell.Offset(0, 9).Value = VSmonth
ActiveCell.Offset(0, 10).Value = VSpreviousmonth
ActiveCell.Offset(0, 11).Value = VSpreviousyear
ActiveCell.Offset(0, 15).Value = vtemonth
ActiveCell.Offset(0, 16).Value = vtepreviousmonth
ActiveCell.Offset(0, 17).Value = vtepreviousyear
Else
End If
ActiveCell.Offset(1, 0).Select
Loop
Else
End If
End Sub
Quelqu'un pourrait voir, ce serait génial ! SOS
J'ai eu un pb sur la macro de folie, c'était pas moi qui l'ai développée. Elle marchait avant, mais c"était toujours 1 fois sur 5, or cete fois elle marche pas du tout!!!
Elle se bloque toujours sur : ActiveCell.Offset(1, 0).Select
La macro est :
Sub synthesesite()
'
'
If MsgBox("LA MISE A JOUR DURE 2 MINUTES. VOULEZ VOUS CONTINUER ?", vbQuestion + vbYesNo, "MISE A JOUR DES DONNEES") = vbYes Then
Application.ScreenUpdating = False
Sheets("RECAP").Select
Range("$A$7:$DK$7").AutoFilter
Range("$A$7:$DK$7").AutoFilter
Sheets("SYNTHESE PAR SITE").Select
a = Range("b7").Value
b = Range("C7").Value
c = Range("D7").Value
d = Range("F6").Value
e = Range("J7").Value
f = Range("K7").Value
g = Range("L7").Value
h = Range("P7").Value
i = Range("q7").Value
j = Range("R7").Value
k = Range("E6").Value
Range("A8").Select
Do While ActiveCell.Offset(-1, 0).Value <> "CENTRALE + MAGASINS"
If ActiveCell.Value <> "" Then
Selection.Copy
Sheets("RECAP").Select
Range("E5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("7:7").Select
Selection.Find(What:=a, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couvmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=b, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couvpreviousmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=c, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couvpreviousyear = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=d, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
stock12m = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=k, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
couv12m = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=e, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
VSmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=f, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
VSpreviousmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=g, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
VSpreviousyear = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=h, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
vtemonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=i, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
vtepreviousmonth = ActiveCell.Offset(-2, 0).Value
Rows("7:7").Select
Selection.Find(What:=j, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate
vtepreviousyear = ActiveCell.Offset(-2, 0).Value
'''''
Sheets("SYNTHESE PAR SITE").Select
ActiveCell.Offset(0, 1).Value = couvmonth
ActiveCell.Offset(0, 2).Value = couvpreviousmonth
ActiveCell.Offset(0, 3).Value = couvpreviousyear
ActiveCell.Offset(0, 4).Value = couv12m
ActiveCell.Offset(0, 5).Value = stock12m
ActiveCell.Offset(0, 9).Value = VSmonth
ActiveCell.Offset(0, 10).Value = VSpreviousmonth
ActiveCell.Offset(0, 11).Value = VSpreviousyear
ActiveCell.Offset(0, 15).Value = vtemonth
ActiveCell.Offset(0, 16).Value = vtepreviousmonth
ActiveCell.Offset(0, 17).Value = vtepreviousyear
Else
End If
ActiveCell.Offset(1, 0).Select
Loop
Else
End If
End Sub
Quelqu'un pourrait voir, ce serait génial ! SOS
4 réponses
-
Bonjour,
Sans doute que tu as changé quelque chose dans ta feuille qui crée le problème car apparemment la macro ne vérifie rien et s'attend à une feuille "nickel" qui est sans doute érodée... -
Bonjour
envoie ton fichier de données avec http://www.cjoint.com/
Cela nous évite de chercher
et ses plus simple pour nous
A+
Maurice-
le lien est: https://www.cjoint.com/?3FsonpAjO87
le fichier est trop grand, j'ai dû supprimé plusieurs onglets, l'onglet dans lequel la macro n'a pas pu marché est "synthèse par site".
Merci bcp^^ -
Bonjour,
Essaies comme ceci, cela devrait fonctionner :
Sub synthesesite() ' ' If MsgBox("LA MISE A JOUR DURE 2 MINUTES. VOULEZ VOUS CONTINUER ?", vbQuestion + vbYesNo, "MISE A JOUR DES DONNEES") = vbYes Then Application.ScreenUpdating = False Sheets("RECAP").Select Range("$A$7:$DK$7").AutoFilter Range("$A$7:$DK$7").AutoFilter Sheets("SYNTHESE PAR SITE").Select a = Range("b7").Value b = Range("C7").Value c = Range("D7").Value d = Range("F6").Value e = Range("J7").Value f = Range("K7").Value g = Range("L7").Value h = Range("P7").Value i = Range("q7").Value j = Range("R7").Value k = Range("E6").Value Range("A8").Select Do While ActiveCell.Offset(-1, 0).Value <> "CENTRALE + MAGASINS" If ActiveCell.Value <> "" Then Selection.Copy Sheets("RECAP").Activate With Sheets("RECAP") .Range("E5").Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False .Rows("7:7").Select Selection.Find(What:=a, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate couvmonth = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=b, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate couvpreviousmonth = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=c, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate couvpreviousyear = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=d, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate stock12m = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=k, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate couv12m = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=e, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate VSmonth = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=f, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate VSpreviousmonth = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=g, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate VSpreviousyear = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=h, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate vtemonth = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=i, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate vtepreviousmonth = ActiveCell.Offset(-2, 0).Value .Rows("7:7").Select Selection.Find(What:=j, After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False, SearchFormat:=False).Activate vtepreviousyear = ActiveCell.Offset(-2, 0).Value ''''' End With Sheets("SYNTHESE PAR SITE").Activate ActiveCell.Offset(0, 1).Value = couvmonth ActiveCell.Offset(0, 2).Value = couvpreviousmonth ActiveCell.Offset(0, 3).Value = couvpreviousyear ActiveCell.Offset(0, 4).Value = couv12m ActiveCell.Offset(0, 5).Value = stock12m ActiveCell.Offset(0, 9).Value = VSmonth ActiveCell.Offset(0, 10).Value = VSpreviousmonth ActiveCell.Offset(0, 11).Value = VSpreviousyear ActiveCell.Offset(0, 15).Value = vtemonth ActiveCell.Offset(0, 16).Value = vtepreviousmonth ActiveCell.Offset(0, 17).Value = vtepreviousyear Else End If ActiveCell.Offset(1, 0).Select Loop Else End If End Sub
Ta feuille recap n'était pas correctement déclarée apparemment. -
-
-
Bonjour
Le problème ne viendrait-il pas du fait que tu ne sors jamais de la boucle si la cellule est vide?
If ActiveCell.Value <> "" Then
else
end if
et tu passes à la ligne suivante
ActiveCell.Offset(1, 0).Select
le programme s'exécute jusque la dernière ligne mais ne peut aller au-dela.
apres Else il manque exit sub
If ActiveCell.Value <> "" Then
else: exit sub
end if
A voir
cdlt -
Bonjour tinyspot0103,
Merci pour ton sympathique retour. J'ai regardé de plus prêt ta macro et je l'ai pas mal modifiée dans le but d'éviter les plantages et d'améliorer la rapidité.
Si tu as le temps, j'aimerais que tu la testes sur une copie de ton fichier réel pour voir si elle fonctionne correctement et rapidement.
https://www.cjoint.com/?CFtwZoYslQY
Il te suffit de tirer le module "synthèse" sur une copie de ton classeur : d'avance merci.