Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calculate only one workbook?

131 views
Skip to first unread message

gary...@my-deja.com

unread,
Nov 17, 2000, 3:00:00 AM11/17/00
to

Is there a way to get VBA (XL97) to recalculate only one workbook if
several are open? Application.Calculate calculates all open workbooks;
Worksheets(1).Calculate calculates only the specified sheet. I would
like to calculate all the sheets of a specified workbook.

How can there not be a way to do this?

Thanks,
Gary Wolf

Sent via Deja.com http://www.deja.com/
Before you buy.

Charles Williams

unread,
Nov 17, 2000, 8:18:11 PM11/17/00
to
Hi gary,
There are two ways of doing this, one of which is a bit dodgy.
following code has not been syntax checked
'-------------------------------------
'- dodgy way: not recommended
'- this will only work if the sheets have no interdependencies,
'- or the interdependencies are in sheet definition order
'
for each osht in activeworkbook.worksheets
sht.calculate
next

'- correct but more complex way
'
' disable all sheets except in active workbook
'
for each obk in workbooks
if obk.name<>activeworkbook.name then
for each osht in obk.worksheets
osht.enablecalculation=false
next
endif
next
'
' calculate everything
'
application.calculate
'----------------------------------

HTh
Charles
_____________________________________
Decision Models Ltd,17 Binswood Avenue,
Leamington Spa,Warks CV32 5SE, UK
Tel: (44)01926-334289 Fax: (44)01926-881487

<gary...@my-deja.com> wrote in message news:8v42bn$2jp$1...@nnrp1.deja.com...

0 new messages