DELAIS ENTRE 2 MACROS

  • Initiateur de la discussion Sylvain
  • Date de début
S

Sylvain

Guest
Bonjour,

Il y a t'il un moyen pour mettre un délais entre deux excution de commande vba ?
je m'explique:
J'ai une macro qui m'enregistre mes données dans une base de données puis j'en ai une autre qui efface les données à l'écran (elle me laisse les zones à remplir vide). Quand j'associe les deux (enregistrement puis effacement), les commandes d'effacement ne laisse pas le temps à l'enregistrement de ce faire.
J'ai essayé ces commandes entre les deux mais ca m'arrete l'enregistrement.

nvlleHeure = Hour(Now())
nvlleMinute = Minute(Now())
nvlleSeconde = Second(Now()) + 5
waitTime = TimeSerial(nvlleHeure, nvlleMinute, nvlleSeconde)
Application.Wait waitTime


Mes commandes pour enregistrer sont la suivante :
Sub enreg_auto()
SendKeys ("^s")
SendKeys "{tab}"
SendKeys "{tab}"
SendKeys "{down}"
SendKeys "{tab}"
SendKeys "~"
End Sub

Mes commandes pour effacer sont la suivante :
Sub Nouvelle_Fiche()
'
' Macro2 Macro
' Macro enregistrée le 12/08/02 par PIGEON SYLVAIN
'

'
Rows("7:129").Select
ActiveWindow.SmallScroll Down:=-113
Selection.ClearContents
Range("C8:D8").Select
Sheets("Table").Select
ActiveWindow.SmallScroll Down:=-63
Range("B9").Select
ActiveCell.FormulaR1C1 = "0"
Range("B16").Select
ActiveCell.FormulaR1C1 = "0"
Range("G9").Select
ActiveCell.FormulaR1C1 = "0"
Range("G16").Select
ActiveCell.FormulaR1C1 = "0"
Range("G23").Select
ActiveCell.FormulaR1C1 = "0"
Range("G2").Select
ActiveCell.FormulaR1C1 = "0"
Range("B2").Select
ActiveCell.FormulaR1C1 = "0"
Range("B35").Select
ActiveCell.FormulaR1C1 = "0"
Range("G35").Select
ActiveCell.FormulaR1C1 = "0"
Range("B42").Select
ActiveCell.FormulaR1C1 = "0"
Range("G42").Select
ActiveCell.FormulaR1C1 = "0"
Range("G52").Select
ActiveCell.FormulaR1C1 = "0"
Range("B52").Select
ActiveCell.FormulaR1C1 = "0"
Range("B54").Select
ActiveCell.FormulaR1C1 = ""
Range("B55").Select
ActiveCell.FormulaR1C1 = "0"
Range("B62").Select
ActiveCell.FormulaR1C1 = "0"
Range("B65").Select
ActiveCell.FormulaR1C1 = "0"
Range("G62").Select
ActiveCell.FormulaR1C1 = "0"
Range("G65").Select
ActiveCell.FormulaR1C1 = "0"
Range("G73").Select
ActiveCell.FormulaR1C1 = "0"
Range("B73").Select
ActiveCell.FormulaR1C1 = "0"
Range("B79").Select
ActiveCell.FormulaR1C1 = "0"
Range("B86").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B87").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B88").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B89").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("B90").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G86").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G87").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G88").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G89").Select
ActiveCell.FormulaR1C1 = "FALSE"
Range("G90").Select
ActiveCell.FormulaR1C1 = "FALSE"
Sheets("Fiche de saisie").Select
End Sub


Merci pour votre aide.
Sylvain
 
S

STéphane

Guest
bonjour


Pour ta macro d'enregistrement, je te conseille de voir les méthodes qui sont ici : <http://xlbysteph.free.fr/aideinformatique/actionfichier.htm>

Si l'emploi de la méthode waittime ne marche pas, utilise la méthode doevents à la fin de ta macro d'enregistrement, cela donne la main au système pour qu'il finisse ce qu'il est entrain de faire.

Voilà une simplification de la macro (que tu as enregistrée avec une macro ?)
Rows("7:129").ClearContents
[B54].FormulaR1C1 = ""
[B9,B16,G9,G16,G2,B2,B35,G35,B42,G42,B52,G52,B55,B62,B65 , G62, G65, G73, B73, B79].FormulaR1C1 = "0"
[B86, B87, B88, B89, B90, G86, G87,G89,G90].FormulaR1C1 = False

NB : la notation des cellules entre crochets est l'équivalent de la méthode evaluate et te permets là de créer un raccourci syntaxique pour range("B54"). On pourrait utiliser ces crochets comme suit : MsgBox [5*4]

bye
Stéphane
 

Statistiques des forums

Discussions
312 356
Messages
2 087 567
Membres
103 594
dernier inscrit
edm