Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to calculate only the active worksheet in Excel?

Tags:

excel

vba

I have a very large number of calculations across multiple worksheets (10+ sheets, 30000+ rows, 250+ columns, about 50% with dependencies).

I have a VBA program that runs through a list of variables, changing them one at a time. This change the values in all the cells with formulae.

I don't need all the sheets recalculated every time I change a variable.

Is there a way to recalculate only the active worksheet or a specified worksheet?

like image 777
Clauric Avatar asked Jun 26 '15 13:06

Clauric


People also ask

How do I select an active worksheet in Excel?

Click the tab for the first sheet, then hold down SHIFT while you click the tab for the last sheet that you want to select. By keyboard: First, press F6 to activate the sheet tabs. Next, use the left or right arrow keys to select the sheet you want, then you can use Ctrl+Space to select that sheet.

What is the keystroke for calculating the active sheet in an Excel workbook?

The SHIFT + F9 key helps to calculate only the active worksheet, in a workbook.

How do I count the number of active sheets in Excel?

You can easily use the sheets formula, in any empty cell you can type =SHEETS() and that's it. it will count all the sheets in the workbook. Show activity on this post. Insert a module in the workbook of which you want to count the total number of sheets of.


2 Answers

ActiveSheet.Calculate

or

vbasheetname.Calculate

or

Worksheets("Sheet1").Calculate

It's better practise to avoid using activesheet if possible in your code (there's only rarely a need for it), so try and stick to the second two.

like image 137
tea_pea Avatar answered Oct 13 '22 21:10

tea_pea


One way to do it without VBA is to make the formulas to be dependent upon a boolean cell. If the bool is true, then they calculate, otherwise they do not.

Then in this boolean cell, type this formula: =CELL("filename") = CELL("filename", [B1]). Then place a simple toggle button on this sheet that is linked to any cell in the worksheet. Then, whenever the toggle button is pressed, the linked cell will change values, which will cause the formula in the boolean cell to produce TRUE rather than FALSE, and all the cells that are dependent upon this boolean cell will then calculate.

Example #1

Example #2

This won't keep the cells from calculating, but it will make their calculations super quick.

like image 23
Ben Avatar answered Oct 13 '22 19:10

Ben