Code explanation

vbalearner11

New Member
Joined
Jan 19, 2018
Messages
18
FolderLoc = FolderLoc & "" & "Jan" & ". " & Year 'Inside the Folderloc there are ten's of file and each and every files has atleast three more files in it.
Set FSobj = CreateObject("Scripting.FileSystemObject")
Set ProjectsFolderObj = FSobj.GetFolder(FolderLoc)
For Each BCFolderObj In ProjectsFolderObj.SubFolders
DoEvents

May I know what each step is doing
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
1: creates a string variable that is the starting folder location that the rest of the code will look at - looks like Jan is hardcoded, followed by the year which must be defined earlier

2: creates a "File System Object" called FSobj that exposes a whole set of methods and properties for the object

3: creates a "Folder Object" using the "GetFolder" method of the FSobj object and the Folder location defined above.

4: starts a looping flow control that will process all of the SubFolders in the Folder Object created above (referencing the "SubFolders" collection of the ProjectsFolderObj

5: DoEvents just lets your system process any other events that it might need to do (so the macro doesn't consume 100% of your workstation processors)

following this there is probably some code that processes some action on BCFolderObj
the looping flow control is ended with a "Next" statement.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top