I met an issue when I use range.calculate() in VBA.
The following is situation:
32bit Excel 2010 version; Windows 7
50K records as input, being processed one by one;
When running, excel uses ~400M memory;
Links are built in excel tab; the links among cells don't follow from left to right, top to down rule. there are many back and forth links.
call worksheet.range.calculate() in VBA for the calculations in the cells;
Code:
...
Application.Calculation = xlManual
Worksheets("Curve").Range("A1:BO600").Calculate
...
Problem:
Based on Microsoft instruction, Range.Calculate in Excel 2010 resolves the dependencies within the range being calculated. But based on my debugging, Range.calculate() calculates cells from left to right and top to bottom, ignoring all dependencies, just as excel 2000 version. Then the calculation of next record will use the result of the previous one (stored in excel cells now) rather than the refreshed result of its own record since the depended cells may have not been calculated.
It doesn't recur every time when I run my models. I met this issue 2 months ago, after restarted my PC with applying some windows updates automatically, the issue disappeared and Range.Calculate() works as expected in the past 2 months. Now the issue comes back and I could not get rid of it with PC shutdown, or excel closing.
More importantly, if I switch to worksheet.calculcate(), the issue has gone but the running takes more time.
Any clue on this problem? Thanks a lot in advance.
Leal
Related
I have an Excel file on SharePoint.
Multiple people edit said file.
Offline and online.
Excel unfills all calculated cells (VLOOKUP and MATCH) that depend on other sheets in the same workbook at random.
So if you would open or reload that file, suddenly all the cells that use VLOOKUP or MATCH would be blank.
Upon further investigation nobody changed anything or deleted anything.
It just happens randomly.
Now it has happened 2 weeks ago and just today.
I have an interim solution that is to go to a cell with a formula, hit return, then click „overwrite all cells in this column with this formula“ and then click undo to prevent custom cell content to be overwritten.
Everything is back to normal afterwards.
I talked to a colleague, he has the exact same issue also totally at random.
He also encountered this on files that are not being edited by multiple people but himself.
So it is not dependent on the file itself.
Could the language play into this problem?
On some PCs Excel is in English and on some in German.
=IFERROR(IF(ISNA(VLOOKUP(D185,Sheet1!$B$3:$D$616,3,FALSE)),(VLOOKUP(D185,'Sheet2'!$B$3:$D$22200,3,FALSE)),(VLOOKUP(D185,Sheet1!$B$3:$D$616,3,FALSE))),"")
Seems like your sheet isn't calculating upon open. See if this link is of use to you.
https://superuser.com/questions/448376/what-is-the-excel-hotkey-to-re-calculate-all-formula-in-sheet
Also check your program settings and see if auto-calculate sheets is enabled. Don't know from the top of my head where it is located.
Alternative create a small vba function to force recalculate on workbook open.
Getting Excel to refresh data on sheet from within VBA
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 am using the 64-bit version of Excel and have an Excel Macro workbook I have created and been using successfully for the last year. Today my workbook started crashing when doing a weekly daily upload that has not previously been an issue (no debug, just crashes and exits completely). I have gone through line-by-line and have found that crash occurs after using the Intersect() method.
This was not a problem when I used the same workbook last week.
I have rewritten a number of these Intersect() instances to use a different functionality to refer back to the same range which has solved the problem I am experiencing today, but I am trying to figure out why the Intersect() method is causing a crash in the first place so I can better design future macros.
This is a weird one.
I have an excel file with formulas which is emailed back and forth between users in different countries (different language settings more than likely).
To get the formulas to calculate, you hit enable editing which calculates all the formulas in the workbook.
On windows 10, I receive a file and when I hit enable editing, the formulas do not calculate unless I manually go into each one and hit return. If I open the same file from windows 8, it calculates.
The formulas are correctly in as "custom" and automatic formula calculation is on, the sheet does not calculate if you hit calculate now. There are no circular references.
Another fix I tried was replacing all the = signs with =.
Anyone come across this issue? I do not have details of applied updates to office but I am assuming the sender and the receiver are up to date.
I am not sure how that happens or why the method I am describing works, but it works for me.
Using text to columns, select fixed width but don't actually separate anything to columns and hit finish. You should get all the results of the formula. However it is a real pain if your formulas are in many different columns.
Short version, my Excel is set properly to automatically update links and all my files(locally stored) work fine for years. Suddenly one will not update linked data. I click on Connections>Edit connections>Check Status every linked file has "Warning! Values referring to other workbooks were not updated"
Refresh/calculate all does nothing.Changing to manual and doing this, back to auto, open and closing, restarting, using these same files on another PC. Nothing I did fixes it.
Clicking into an individual cell(F2) then back out though updates that one cell.
Open
All security settings are correct I am 98% sure, regardless whatever settings I had haven't changed and it did work.
I read a post that seemed exactly the same but his solution was enable protected content. Not the case here, i disabled it fully. There seems to be an error causing this possibly..
Long version. This is my largest file I continue to build
I have a main excel sheet that is linked to 35 workbooks. The source workbooks have lists of 3-4 columns, ranging from 1,000-10,000 rows long. The main WB uses index match for each source to pull two small fields. It takes about 5-6mins to do a calculate all with a desktop i7 3.64ghz ivy with 16gb ram.I never have issues on. Win 10/64bit and office 2016 64bit.
Some source files are .xls, I am in the process of changing them to xlsx but when I open the xls file and the values update. I then save as xlsx with a shorter name as well (trying to lighten the formulas) I go back to Connections>Edit connections>Check Status and the same warning is there. However I can click update values and it says OK.
This is very important file and is not physically monitored. Until something sells wrong I realize it wasnt updated, I am hoping for a concrete answer I can solve instead of just changing random things and hoping.. all help is greatly appreciated!
I actually resolved this by opening all source workbooks with the main workbook open and resaving them one by one (Status on some turned OK, most remained). Then I simply used Edit Links and Update Values for each connection which changed the status to OK. Saved the main workbook and no more issues..
Yes I need to take those suggestions and the workbook to the next level as it has clearly outgrown my skillset, but getting there..