So I am trying to achieve a task where I would fetch values from an excel file. Make the necessary modifications to the values, and then add them to the Powerpoint Presentation.
Hence, to achieve the goal. I used the developer tools in Power point and started writing a vba script. Now the Goal of getting values from another excel file and adding them to powerpoint, was more simple and straightforward. HOWEVER, when I am trying to fetch some Specific values from the excel file.
For Example, the Values, who have value of "5" in Column C (which will only have number 1-5).
And I was wondering/Confused as to what approach would be more faster/efficient in this case.
Option A) Use Autofilter, to filter the list, and then loop through the now visible Cells? Option B) Go through all the columns, and then fetch the values?
I was wondering if the AutoFilter Excel Provides has some sort of advantage over normal For Each Loop in Vba? And Hence would be faster?
NOTE: The VBA Script will be ran from powerpoint, So To Use Excel Workbook and commands, I need to create an object of "Excel.Application"
Edit: Correction of naming.
If it comes to speed in Excel, then you need to think of the follwing things:
So if we assume 10000 cells and you loop through them this is 10000 read access to your cells. You can reduce that a lot by reading all of them into an array and loop over the array instead. This way you have only 1 read access instead of 10000.
and if you need to write the data back it can be done with 1 write access for all teh data aswell
So whether filtering data and looping over the filtered data or looping through the array of the entire data is faster highly depends on the data itself as well as on the filter rules you want to apply. So the only way to find out which one is faster is by trying and measuring the time.
For example if you have 10000 rows and after filtering there is only 3 left then the filter might be faster than looping over the array of 10000 rows.