Ah oui, veuillez m'excuser, je vais reformuler ma demande :
Je souhaite vérifier dans mon fichier pilotage (test-date.xlsm), si le fichier externe 211119_VL.xlsx que j'ai exporté à des lignes qui sont à la bonne date que mon fichier pilotage, j'ai fait une petite macro mais je n'arrive pas à comprendre pourquoi :
- Celui ci ne passe pas sur ma condition de vérifier si les valeurs dans 211119 correspondent bien aux date dans pilotage ( 19/11/2021 ou 20/11/2021 ou 21/11/2021)
-La boucle tourne sur un autre fichier dont le nom de la feuille n'est pas égale aux nom mentionné en B18
Option Explicit
Sub controle_date_import()
Dim wb As Workbook
Dim toute_source As Worksheet
Dim Input_EOS As Workbook
Dim Controle_date As Worksheet
Dim date_reporting As Date
Dim j As Long
Dim path_EOS As String
Dim fic_EOS As String
Dim fichier1 As String
Dim fin As Boolean
Set wb = ThisWorkbook
Set toute_source = wb.Sheets("source")
date_reporting = toute_source.Cells(1, 1)
path_EOS = toute_source.Cells(18, 1)
fic_EOS = Dir(path_EOS)
fichier1 = toute_source.Cells(18, 2)
' Controle Date fichier EOS
Do While fic_EOS <> ""
If fichier1 <> toute_source.Cells(18, 2) Then fin = True
Workbooks.Open path_EOS & fichier1
Set Input_EOS = Application.ActiveWorkbook
For i = 2 To Input_EOS.Sheets(1).Cells(Rows.Count).End(xlUp).Row
For j = 19 To toute_source.Cells(Rows.Count).End(xlUp).Row
If Input_EOS.Sheets(1).Cells(i, 6).Value = toute_source.Cells(j, 1) Or Input_EOS.Sheets(1).Cells(i, 6).Value = toute_source.Cells(j + 1, 1) Or Input_EOS.Sheets(1).Cells(i, 6).Text = toute_source.Cells(j + 2, 1) Then
toute_source.Cells(18, 3) = "OK"
ElseIf Input_EOS.Sheets(1).Cells(i, 6).Value < toute_source.Cells(j, 1) Then GoTo erreur
End If
erreur:
toute_source.Cells(18, 3) = "Pas OK"
Exit sub
Next
Next
End if
Input_EOS.Close savechanges:=False
fichier1 = Dir(fic_EOS)
Loop
End Sub