PDA

View Full Version : Question on ActiveWorkbook.Calculate



volabos
10-16-2012, 06:18 AM
I have an quick question. The VBA code ActiveWorkbook.Calculate does not calculate for all sheets in the active workbook?

I believe NO. Can somebody verify it? If it is not then what will be the VBA code to calculate for all sheets for the active workbook.

My workbook is presently set as 'Manual calculation' which I want to preserve because it is quite large size.

Thanks and regards,

p45cal
10-16-2012, 06:55 PM
Application.CalculateFull
?

It'a for all open workbooks.

Help says Calculate is the same.

Check out also:
Application.CalculateFullRebuild

Teeroy
10-25-2012, 02:35 AM
You are right, .Calculate won't work on a workbook. The method only applies to the Application (all open workbooks), a worksheet, or a range (at least in excel 2003). If you need it limited to a specific workbook loop through the worksheets collection.

magelan
10-25-2012, 08:00 AM
You are right, .Calculate won't work on a workbook. The method only applies to the Application (all open workbooks), a worksheet, or a range (at least in excel 2003). If you need it limited to a specific workbook loop through the worksheets collection.


Dim i As Integer
Dim wsheet As Worksheet
For i = 0 To UBound(Worksheets)
wsheet = Worksheets(i)
wsheet.Calculate
next

Teeroy
10-26-2012, 04:20 AM
Dim i As Integer
Dim wsheet As Worksheet
For i = 0 To UBound(Worksheets)
wsheet = Worksheets(i)
wsheet.Calculate
next
You are right Magelan, I shouldn't have assumed that the looping was was obvious. Another way to do this is:

Dim wsheet As Worksheet
For Each wsheet in Worksheets
wsheet.calculate
Next