Sub Reims()
Dim fichier$, Chemin$, source As Workbook, cible As Workbook
Dim lig%, dlg%, x&, i&, fin&
Application.ScreenUpdating = False
Chemin = ThisWorkbook.Path
Set cible = ThisWorkbook
fichier = Chemin & "\Reims\Suivi Camionnage.xls"
fin = Sheets("SD").Range("A65536").End(xlUp).Row
For i = 2 To fin
If fichier Like "*" & Sheets("SD").Cells(i, 1) & "*" Then x = Sheets("SD").Cells(i, 2): GoTo 1
Next i
1
[COLOR="Red"][B]On error resume next[/B][/COLOR]
Set source = Workbooks.Open(fichier)
[COLOR="Red"][B]On Error GoTo 0
If source Is Nothing Then
MsgBox "Pas de Fichier", , "vérifier votre classeur"[/B]
Else[/COLOR]
With source.Sheets("Données")
dlg = cible.Sheets("Données").Range("A65536").End(xlUp).Row + 1
lig = .Range("A4:A2000").Find("", , xlValues, , 1, 1, 0).Row
Application.DisplayAlerts = False
.Range("A4:M" & lig).Copy
cible.Sheets("Données").Range("B" & dlg).PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
cible.Sheets("Données").Range("A" & dlg & ":A" & dlg + lig - 5) = x
cible.Sheets("Données").Range("A4:N" & dlg + lig - 5).Font.Name = "Times New Roman"
cible.Sheets("Données").Range("A4:N" & dlg + lig - 5).Font.Bold = False
End With
source.Close SaveChanges:=False
Application.DisplayAlerts = True
Unload Agence
MsgBox "Traitement effectué", , "Importation du fichier Reims"
[B][COLOR="Red"]end if[/COLOR][/B]
End Sub