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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| 'Exportation du fichier Nova chaque matin à 9h
Public Sub Robot()
Dim mydate As Date
Dim wsOIL_Spot As Worksheet
Dim wsFX_Spot As Worksheet
Dim lastOILSpotDate As Date
Dim lastFXSpotDate As Date
Dim lastNovaExportDate As Date
Dim exported As Boolean
exported = False
Set wsOIL_Spot = ThisWorkbook.Sheets("OIL_Spot")
Set wsFX_Spot = ThisWorkbook.Sheets("FX_Spot")
mydate = Date
If Weekday(mydate, vbMonday) = 1 Then ' si nous sommes lundi
mydate = Date - 3 ' gestion weeckend , si lundi, exporter les données du vendredi précédent
Else
mydate = Date - 1
End If
lastOILSpotDate = CDate(mydate)
lastFXSpotDate = CDate(mydate)
lastNovaExportDate = IIf(Weekday(mydate, vbMonday) = 1, CDate(mydate) - 3, CDate(mydate) - 1)
'Gérer les week ends. 6 is saturday and 7 is sunday
If Weekday(mydate) = 1 Or Weekday(mydate) = 2 Or Weekday(mydate) = 3 Or Weekday(mydate) = 4 Or Weekday(mydate) = 5 Then
Application.OnTime TimeValue("09:00:00"), "Procédure_Export" 'lundi
Application.Wait TimeValue("00:00:05")
Application.OnTime TimeValue("09:00:00"), "Procédure_Export" 'mardi
Application.Wait TimeValue("00:00:05")
Application.OnTime TimeValue("09:00:00"), "Procédure_Export" 'Mercredi
Application.Wait TimeValue("00:00:05")
Application.OnTime TimeValue("09:00:00"), "Procédure_Export" 'Jeudi
Application.Wait TimeValue("00:00:05")
Application.OnTime TimeValue("09:00:00"), "Procédure_Export" Vendredi
End If
End Sub |
Partager