xlcalculationAutomatic not working

switters_aka

Board Regular
Joined
Oct 26, 2010
Messages
118
Hello all, I am running this code to refresh a sheet which has a vba function to calculate values in a cell. For some reason, the function is constantly producing #value errors but on refresh, the function works. The problem is, the refresh sub() is doesn't always work. If I modify it in some way, even if it means removing a blank line, then it works. It's one of those intermittent problems which does your head in. Any ideas where I might be going wrong?

Code:
Public Sub refresh()


   Application.Calculation = xlCalculationManual

  Application.Calculate

  Application.Calculation = xlCalculationAutomatic

Application.ScreenUpdating = True
End Sub
 
Does this happen in any workbook, open on its own?
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
when I execute this line of code, Application.Calculation = xlCalculationAutomatic, my VBA program just stops. There's no error message, no break, no crash; the program just stops, as if it encountered an "End" statement.

"Just stops"? Or is it really spinning its wheels for a very very long time?

What does Task Manager tell you about CPU usage?

Caveat: The %CPU number can be deceptive on multi-CPU multicore systems. The question really is: is one "CPU" (or core) 100% busy?

I suspect it is. Reason: setting auto calculation mode might cause Excel to recalculate a huge number of formulas, and that might take many seconds, minutes, hours, even days.
 
Upvote 0

Forum statistics

Threads
1,214,895
Messages
6,122,128
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top