Free Excel VBA Macro Tutorial-VBA Macro - Loop Through all folders, subfolders and files with size

preview_player
Показать описание
Free Excel VBA Macro tutorial - Loop Through all folders, subfolders and files with size via Excel - Loop till last folders and files and extract the details with size - Loop through folders - Loop through files - Loop through all - youtube #youtubechannel #youtubevideo #vba #vbamacro #vbamacros #youtubervba

uh welcome to technology platform so let's continue this session now so earlier session we saw that how to access the files uh based on the folders now we want to see how to access the sub folders the same uh using code itself so now we already written here and the same thing but again one another for each loop

and variable is like subfolders list and declaring a variable here and then in folder dot so i used files now i used subfolders

next that's it so now here i want to

again go to the folder path now to reiterate when the folder has no subfolders or no sub files till now i need to loop it so what i can do here is like again i want to use call

so inside process itself i want to call it get sub folder files

and the folder path same folder path press

this one then the subfolder list dot name means that is folder name here yes the subfolder files now if you here see this um so technology platform earlier we access only this file now i want to click on this folder one and slash folder once slash so this g dot platform is the folder path and then i am adding slash and then folder one then it will go like this so that is i'm accessing via code here for each subfolder list in subfolders and then name i call it out here now before that i want to do that first i count whether it's folder is present or not now that if folder dot subfolders dot count greater than 0 then only i will call this loop other way i should not call it so now um we can run it we'll see what is happening here and then we'll decide so we are accessing the files here we are accessing the folders here and calling it out f8 f8 select technology platform given okay

the platform calling the functions a process method whatever if it is folder path creating an object accessing the platform folder and accessing the files

so this one is trouble to ticks and this is size of the file and i plus one there is no more additional file should be now it has come to here folder does subfolders greater than 0 now subfolders folder 1. now again if you see here g dot technology platform and this one is folder one now it will commit over here now the folder one files we are going to access see this

so i can use if i know we will see excel

yeah we can see uh so many files but something happened here we have so many files inside so many files but we could see only few

we could see only four files something is overwritten because i'll delete here remove it and again effect effect selecting the folder effect effect f5 now see the range go to excel sheet now this one triple two x f eight five effect

you see this game again if you press f8

it's overwritten so to avoid this what i am going to do here is like here i equal to i plus 1 so so for that i i want to always insert one row and then i will insert mine so for that

i am going to write here is like i equal to

and then

now let me effect render f8 if it select the technology platform okay a platform now this is i equal to four

now see this even though four it additionally had one row and then it started to write now f8

let's see this again here adding additionally one row so so like that it is adding right f8 effect now see this this is one folder

in another folder i'll press f5 now now see this so this is folder one this is folder two and this is folder three so something is gap is here that is not required so i remove this one and one now see this

now see this

f5 select the folder okay this one now see everything has came like this

so all we achieved by using this folder list but what it is this one i'll tell you now um now i hope this is clear now i'm going to record macro here record macro macro one here i'll select this one and then control up arrow i'm pressing moving up here now stop the macro and then you can see here

macro one edit you will see this excel up so i used end excel up in the xlr so that means what i am saying to the program is like wherever the cursor is just go to top and then insert one row and add it here so that the overwritten will be a wider so this is the simplest function where we can achieve it easily let me show you

okay so if you see here so only by using this simple functions we can extract all the files and folders of folders including everything so thanks for watching
Рекомендации по теме