السلام عليكم و رحمة الله و بركاته
انا مسوي برنامج و مسوي ملف فيه كل ملفات النسخ الاحتياطية ، لكن لحظت ان الملفات صارت كثيرة
انا اريد ان احتفظ باخر 6 ملفات تم انشاء فقط
انا لقيت هذ الكود في النت
Dim fs As Object
Set fs = Application.FileSearch
With fs
LookIn = "C:\" & InputBox("Enter Folder Name", "Folder?", "Default Folder Name Here")
FileName = InputBox("FileType", "*.doc, *.mdb, *.xls, *.txt, " * "")
' (SortOrder:=1)ASCENDING (=2)DESCENDING
If .Execute(SortOrder:=1) > 0 Then
MsgBox "There were " & .FoundFiles.count & _
" file(s) found."
Else
MsgBox "There were no files found."
End If
End With
Set fs = Nothingلكن لما اشغل الكود يطلع لي مشكلة هنا
Application.FileSearch
ارجو الافادة

