I have a powerpivot table and one slicer with several values. I have a macro that loops over my slicer and makes a copy of the data and paste the values in another excel
After any data update when I change the slicer Excel takes some time to query or recalculate values and in the cells appear "#######" during some seconds until the the new data are loaded.
This is a problem for my macro because it is copying this characters instead of the values. I have try two approaches to give more time to the loading process:
Create a Wait of 5 seconds that is more than enough before copy-pasting the data
Put a Msgbox to stop the copy pasting.
None of them work. Both of them seems to interrupt the loading process that I though will run in the background.
Is there any event in vba that notifies me when the data are loaded?
For those who can't use CalculateUntilAsyncQueriesDone because it hangs indefinitely, I devised a solution for this. It's blunt but it works.
https://stackoverflow.com/a/40792389/1540567
Related
I am working with an Excel 2013 workbook on Windows 10. It has ten pivot tables and takes a long time (~2 mins) to open. I have tried a lot of things to speed this up to no avail. Here are the specs:
The workbook is about 40 Mbytes in size. It is an *.xlsm file with a significant VBA app that can be activated by clicking a button. However, there is no Workbook Open event and no worksheet level events.
All of the pivot tables are based on data from a single worksheet within the workbook. No external data.
All of the pivot tables are set to NOT refresh on open. They are also set to not save data. (I tried both ways and if anything setting it to save data caused it to take longer to open.)
The pivot tables contain no formulas. The data worksheet has no formulas. The workbook in its entirety has very few formulas. The app creates formulas to populate the sheets, but then converts all of the formulas to values.
The pivot tables did have conditional formats, but even after deleting them all, the workbook still takes about the same time to come up.
This is not the startup delay issue. There is a dialog telling me that the load is 0% … 20% … 40% … complete.
I deleted just the pivot table sheets from the workbook and the workbook comes up in just a few seconds.
I also created a new workbook by copying over all the sheets and code thinking there might be a low-level corruption issue, but the copy didn't come up any faster.
Do pivot tables just naturally come up slow? Is there any property or setting I can change to speed up the workbook opening process? A number of people use these workbooks and are very dissatisfied.
Right click inside pivot, Pivot Table options, Data tab, clear/uncheck the checkbox "Save source data with file."
Every time you create a Pivot, Excel stores a copy of the source data in the file and uses it to run queries. If you created 10 Pivots separately, you'll have 10 caches saved in the file making it bloated/slow. To optimize the file, you'll want to create a Pivot and then COPY that Pivot for ALL other Pivots that use the SAME data table. This will ensure you use only 1 cache instead of 10. Also, as a bonus, when you refresh one it'll refresh all of them.
**Only keep this unchecked if there's no external data.
Cheers
Currently I’m using Excel Application Scope which is unchecked AutoSave and unchecked Visible, and using Save Workbook as the first picture below.
Estimated execution time is 10 minutes.
Adding new sheet is slower as the sheets increase.
Use the Write Range activity instead. This will be 4-times faster.
I need to provide a current list of files in a directory in an Excel workbook and everything is working as required, just too slowly. I really only need the list to check it is current once upon opening the workbook. It takes around 11 seconds to do this which is acceptable but the problem is it keeps rechecking this every time I carry out even minor edits to the workbook (I guess due to the fact that it is brought in as an Excel table). I determined the lag in my workbook using the rangetimer() function that is provided and it is the only thing taking a long time to calculate. I should also state that the table containing the list of files is finally used in a cell on another worksheet to provide a data validation drop-down list but don't believe this is really the issue.
I did some Googling on reducing Excel calculation times and discovered that there are some Excel functions that are definitely culprits for increasing calculation times (described as volatile) and three of these (NOW,INDEX and ROW) are used in providing the functionality I would like in this part of the workbook.
I have tried two solutions so far:
1. Force Full Calculation set to True in VBA properties window
2. Switched calculations to manual. I set this back to automatic once I identified that this part of the workbook was the issue as I don't want manual calculation generally.
The formula I have in the 'refers to' box of the named range (TutorFileList) is:
'''=FILES("\O008DC01\Shared\Tutor Qualifications*")&T(NOW())'''
The formula I have in each cell of the excel table is:
'''=IFERROR(INDEX(TutorFileList,ROW()-1),"")'''
What I would like to have is the ~11secs of calculated time to find these files reduced down to just one check of the networked directory rather than it taking 11secs of automatic recalculation every time the workbook is modified.
If there is a more efficient way to achieve what I am doing I am prepared to redesign things but I do need the functionality of a drop-down list of files in the specific directory in a cell.
Many thanks for assistance from anyone on this.
I have resolved my issue by reducing the number of rows back to around 200 instead of 500 rows. This brings the calculation lag back to about a second which I can live with.
I have 5 workbooks with 540 column x 50 row blocks of data.
I also have a 'roll-up' workbook that lists all this data on a single worksheet with links. There are 6 conditional formatting rules.
The roll-up workbook takes ~30 seconds to update links on open and takes 1-2 seconds each time i modify data and move around the worksheet.
I feel like Excel should be able to work with this data in a performant manner.
Am I doing anything wrong? Should i have set things up differently?
I've tried using arrays of links and individualy linked cells and not noticed a difference.
-- EDIT --
When I remove the conditional formatting, the 30 second refresh takes 1 second. Additionally, some Data Validation dropdowns speed up from 6 seconds to immediate. I'll look at ways of removing the Conditional Formatting (like the VBA idea below).
I don't think the problem is in the conditional formatting but rather, it is in the fact that you need to open data from 5 different workbooks. Trying to consolidated those workbooks first would improve the speed. Refreshing data connections takes 30 sec.
Alternatively, instead of a linked cell, try to use designated data connections (as you would in Power Query, for example). This way a refresh wouldn't happen automatically but the responsiveness of the main spreadsheet would improve.
From experience, conditional formatting can really slow a spreadsheet down. I had one much smaller template that became unusable due a lot of conditional formatting, so I had to redesign it with VBA code instead. In that case this was workable as the cells didn't change much after the initial set-up, so the script only needs to be run once. It would not be so workable if the data is likely to change often.
You might consider putting the formatting in a VBA script, depending on how often the data (and hence the formating) is likely to change.
When you create a custom-user defined function in VBA that can be used as a regular spreadsheet function, I can't seem to stop it from auto calculating during, before, and after run time.
The data is in a table format and auto populates when adding extra rows. When I set application.calculation to xlmanual, the macro still iterates over each row to ensure that the user defined function is calculating - but there doesn't seem to be a way to pause that and significantly decrease runtime. Why is it that every row in a table with a custom-user defined function keeps getting triggered when something interacts with it?
Another potential symptom - what is what's even more problematic is that when I click on a cell(when the macro isn't running) containing a formula, each and every row still auto calculates even when set on manual.
This seems to be a bug, or maybe the downside of using a table list object. Any way around this?
Let me know if I explained the question well, or I can continue to revise this for a productive answer.