Programmer le lancement d'une macro VBA
Bonjour le Forum
J'ai écris un code qui me permet de copier et d'insérer dans un onglet des données (j'ai adapté ce code d'après une discussion du forum "Programmer un enregistrement hebdomadaire en VBA ?"
Je cherche à automatiser ce code en le lançant une fois par semaine mais ça ne marche pas
Excel sera toujours ouvert
Dans le ThisWorkBook
Code:
1 2 3 4 5 6
|
Private Sub Workbook_Open()
Application.OnTime TimeValue("09:33:00"), "Sauve"
End Sub |
Dans un module
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Sub Sauve()
'Macro enregitrée par jfo le 21/04/2015
If Weekday(Date) = vbSaturday Then
Dim DLig As Integer
With Sheets("Compteur") 'Sélectionne la feuille Compteur
DLig = .Range("A" & Rows.Count).End(xlUp).Row + 1 ' Positionne sur la bonne cellule
.Rows(DLig).Insert
'Recopie des formules
.Cells(DLig, "A") = Cells(DLig - 1, "A").Value
.Cells(DLig, "B").FormulaR1C1 = Cells(DLig - 1, "B").FormulaR1C1
.Cells(DLig, "D").FormulaR1C1 = Cells(DLig - 1, "D").FormulaR1C1
.Cells(DLig, "E").FormulaR1C1 = Cells(DLig - 1, "E").FormulaR1C1
.Cells(DLig, "G").FormulaR1C1 = Cells(DLig - 1, "G").FormulaR1C1
.Cells(DLig, "H").FormulaR1C1 = Cells(DLig - 1, "H").FormulaR1C1
.Cells(DLig, "I").FormulaR1C1 = Cells(DLig - 1, "I").FormulaR1C1
.Cells(DLig, "J").FormulaR1C1 = Cells(DLig - 1, "J").FormulaR1C1
'Récupération des données de la feuille "Récap Prises"
Sheets("Récap Prises").Cells(24, 8).Copy Sheets("Compteur").Cells(65535, 3).End(xlUp)(2)
Sheets("Récap Prises").Cells(37, 8).Copy Sheets("Compteur").Cells(65535, 6).End(xlUp)(2)
Application.CutCopyMode = False
End With
End If
Application.Wait "09:33:01"
Application.OnTime TimeValue("09:33:00"), "Sauve"
End Sub |
Si besoin je joint le fichier
Je suis assez novice en vba et je demande votre aide
D'avance merci pour votre aide et votre disponibilité