Importer sans doublon

zizoufan

XLDnaute Occasionnel
Bonjour à vous les amis,

j'utilise une macro pour parcourir un répertoire et lister l'ensemble des fichiers qu'il contient. Y-a-t-il un moyen de faire en sorte que si je veux importer le même répertoire qu'il prenne juste les nouveaux éléments sans doublons ? Merci par avance

Public Sub LoadFichier()
Dim total_enregistrements As Integer
Dim SousRep As Boolean
total_enregistrements = 0
Rep$ = FLoadNomDuREP
If Rep$ = "" Then Exit Sub
SousRep = False: If MsgBox("Avec les sous dossiers ?", vbQuestion + vbYesNo, "Dossiers") = vbYes Then SousRep = True
'départ
Dim RepDeBase As Variant
Set RepDeBase = CreateObject("Scripting.FileSystemObject").GetFolder(Rep$)
Application.ScreenUpdating = False
Cells(1, 1) = "Liste des enregistrements disponibles"
Range("A1:E1").Select
Cells(1, 1).Font.Bold = True
Cells(2, 1) = "Chemin de l'enregistrement": Cells(2, 2) = "Nom du fichier": Cells(2, 3) = "Crée le "
Cells(2, 4) = "Modifié le ": Cells(2, 5) = "CEA"

LoadFichSuivant RepDeBase, SousRep
'retour
DernLig = Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
'If DernLig <= 2 Then
'ViderLaFeuille
' Cells(2, 1) = "Néant !"
'If DernLig > 3 Then
' Range("A3:E" & DernLig).Select 'tri sur base chemin en Col(E)
' Selection.Sort Key1:=Range("E3"), Order1:=xlAscending, Header:=xlGuess, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
'End If

ActiveSheet.Columns.AutoFit: Range("A1").Select
Application.ScreenUpdating = True
Range("A1:E1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
Selection.Merge
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With
Range("A2:E2").Select
Range("E2").Activate
With Selection.Interior
.ColorIndex = 40
.Pattern = xlSolid
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
total_enregistrements = Application.WorksheetFunction.CountA(Range("A3:A65536"))
Sheets("TdB").Range("D2").Value = total_enregistrements

Range("A12").Select

End Sub
 

Discussions similaires

Statistiques des forums

Discussions
312 319
Messages
2 087 213
Membres
103 494
dernier inscrit
JP9231