Тёмный

FILES Function in Excel to List Files in a Folder 

ExcelMoments
Подписаться 5 тыс.
Просмотров 4,4 тыс.
50% 1

In this video, I use the Excel4Macro function FILES to list all the files in a folder path, I also show how to use wildcards to filter the results
Workbook can be found here:
drive.google.com/file/d/1zCwy...
#FiLESFunction #ListFiles #Excel

Опубликовано:

 

6 мар 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@paulsprunken
@paulsprunken Год назад
Wow, a teacher that doesn't only give me the solution but also walks me step by step through the solution, allowing me to acquire some understand of funcxtions and vba; I like your style man, much appreciated
@ExcelMoments
@ExcelMoments Год назад
Excellent feedback. Thank you so much
@paulsprunken
@paulsprunken Год назад
@@ExcelMoments Question pls: my macro runs in error because of duplicate filenames (after trimming the original filenames). This is totally correct. My list of filenames has an ordernumber and a specific analysis document number associated with that order. I can have multiple orders that reference the same analysis document number and all I need is, after trimming off the ordernumbers, to only have a unique list of analysis document names. But the macro cannot handle the resulting obvious duplicate file names (either to be skipped or overwritten. Instead it runs into a vba macro error state. Any clues or code to add to handle this? Much appreciated!
@paulsprunken
@paulsprunken Год назад
@@ExcelMoments I got confused it is runtime error 58 file name exists. I tried to insert the line On Error Resume Next but it continues getting stuck in error. Hope you can guide me pls
@ExcelMoments
@ExcelMoments Год назад
@@paulsprunken What i may suggest ifs doing a FILE EXIST check prior to renaming, so if you know the end name after trimming is going to be 123.xlsx, you can check first if 123.xlsx is already a file in that folder, if it is, then you need to modify what your new name is, maybe with an _1,like say 123_1.xlsx. but the trick would be to check first if the new name you are proposing already exists before doing the rename or saving as the case may be
@paulsprunken
@paulsprunken Год назад
@@ExcelMoments Thanks for challenging me and withholding the code of the solution: I Managed with the following (modified from your original) code: Sub Renamefiles() Dim I As Long Dim strFileExists As String Dim strFileName As String For I = 5 To Range("D" & Rows.Count).End(xlUp).Row strFileName = Range("D" & I) strFileExists = Dir(strFileName) If strFileExists = "" Then Name Range("D" & I).Value As Range("E" & I).Value Else Range("A" & I) = "Duplicate" End If Next I End Sub I'm happy, thank you!
@GideonBotes
@GideonBotes Год назад
Very good video, thank you!
@ExcelMoments
@ExcelMoments Год назад
You are welcome
@LuisRiveraAlmeyda
@LuisRiveraAlmeyda 2 года назад
Thanks, it es really helpful, you are awesome.
@ExcelMoments
@ExcelMoments 2 года назад
You are welcome once again
@dustsettler4596
@dustsettler4596 Год назад
Hello! Is there any way to extract the "Date modified" of the files we extract, perhaps in a second column?
@ExcelMoments
@ExcelMoments Год назад
That's a good question. i may just add a short Function in VBA, Function Datemodified(path As String) Datemodified = Format(FileDateTime(path), "dd-mmm-yy hh:mm:ss Am/Pm") End Function So, i would use it like =Datemodified(B4), where B4 contains a fully qualified file path. That is one way
@ExcelMoments
@ExcelMoments Год назад
@@dustsettler4596 you can use Power Query to get a list of all those files and other associate properties. depending on your request, one can provide some guidance, but i definitely like batch files(takes me back in time 😊😊)
@Arsenal_Legend234
@Arsenal_Legend234 3 года назад
Nice one sir
@ExcelMoments
@ExcelMoments 3 года назад
Thanks for the feedback, much appreciated
@Football-jc9tn
@Football-jc9tn 2 года назад
The Files do not come in order. Can u please help?
@ExcelMoments
@ExcelMoments 2 года назад
When you say not in order, what order are you expecting or do you require it in?
@Football-jc9tn
@Football-jc9tn 2 года назад
@@ExcelMoments So I have the files as 1,2,3,4,5 in my folder aligned with certain names. When I do the function it comes as 1,2,4,3,5 in excel which messes up the whole sequence
@ExcelMoments
@ExcelMoments 2 года назад
@@Football-jc9tn The 4-3 for example, any similarity or differences between those names and why Excel is not putting them in order. Worst case, you can do SORT(Transpose(Myfileslist),1,1) for ascending order. although, i expect FILES to get the list already sorted. I would like to see your specific example
@emmanuelmiller3034
@emmanuelmiller3034 11 месяцев назад
it only shows one document from the folder it doesn't show all documents
@ExcelMoments
@ExcelMoments 11 месяцев назад
That should not happen though Are you using Excel 365? if No, that may explain it. In the older versions, you have to use an INDEX to extract the components of the array(List of all files in folder)
Далее
Excel VBA  with FILES function to rename files
7:49
Просмотров 21 тыс.
Давидыч против Тамаева 3 ЧАСТЬ
00:56
СПРАВКА ДЛЯ УНИВЕРА
00:44
Просмотров 372 тыс.
Лайфхак с колой не рабочий
00:16
Просмотров 215 тыс.
Excel FILTER Function TRICK for Non Adjacent Columns
12:03
10 Excel Formulas That Will Set You Apart (Cheat Sheet)
18:04
Давидыч против Тамаева 3 ЧАСТЬ
00:56