The sentenceat the end of the code below, what is its role?![]()
Please Login or Register to view this content.
Thanks!!![]()
Please Login or Register to view this content.
The sentenceat the end of the code below, what is its role?![]()
Please Login or Register to view this content.
Thanks!!![]()
Please Login or Register to view this content.
It calling the Dir again.
Earlier in the code was this line:
That set the DIR parameters and the first filename was collected and stored I the sFil string variable.![]()
Please Login or Register to view this content.
Later, the shorter version you noted:
..effectively calls the same code from above again, the same parameters, but collects the NEXT filename in the same folder. That loop continues each time until all the matching filenames have been collected once. After that the code exits.![]()
Please Login or Register to view this content.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
?None of us is as good as all of us? - Ray Kroc
?Actually, I *am* a rocket scientist.? - JB (little ones count!)
But how does computer know to collect next filename? There is no sentence like "i=i+1" I already know.
Do while is a loop as I=I+1 is.
Thank you for your explanation. But still a little bit confused. I checked the example in Help.
This is a loop with "counter = counter + 1 " as well. Why the previous code without "+1"?![]()
Please Login or Register to view this content.
sFil = Dir(sPath & "*.xls")
sets sFil as all of the files in the diectory
Do While sFil <> ""
Means keep looping until the file name (sFil) is empty (do while not empty)
You should hit F5, because chances are I've edited this post at least 5 times.
Example of Array Formulas
Click the * below on any post that helped you.
It's a VBA thing, that original command simply means "get the first filename in the given path", and when you make the same call a second time using the shorter syntax, it simply means "get the NEXT filename from the same path". You can use the call over and over and each time it will get the NEXT filename until there are no more filenames.
Just trust that's what it means, that's what it does, and use it.![]()
Is it because: for "counter = counter + 1", computer doesn't know how many to add, then we have to tell '+1'. While for Files in one folder, the only way is to open one by one, so we don't need to tell computer.
Ok! I think I have understood much more. Maybe I thought too much. Thankyou all guys!!!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks