There is a task - to write a macro for MS Excel. Macros need to specify a folder, and it must find all Excel files in this folder and perform operations with them:
- Open book
- Copy certain cells
- Paste their contents into another book.
- Close the book
In general, to collect from all files one table. Unlike the usual Python, in the BWA is not clear everything. I read inquiries at the Microsoft office, but for some reason they give false descriptions.
- How to create an empty array so that any number of elements fit into it? I tried
Dim ExcelFiles() As Variant, but nothing can be added to this array. If you specify the length, it works, but I would like to know how to create an empty array. - How to find out the number of elements (length) of an array? The answers found only vague. Analog
Array.lengthin Java Script, for example. - How do cycles work? There is such a fragment:
For j = 0 To UBound(ExcelFiles) Workbooks.Open (ExcelFiles(j)) Workbooks(ExcelFiles(j)).Close SaveChanges:=False Next j
The length of the array is ExcelFiles = 3, but in fact the loop only executes Workbooks.Open (ExcelFiles(j)) for the first element of the array. It does not give any errors. Just pretends as if everything is done correctly.
And most importantly: with what can it be debugged?