ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referring to a worksheet in another file. (https://www.excelbanter.com/excel-programming/373368-referring-worksheet-another-file.html)

Ed

Referring to a worksheet in another file.
 
Hi
I need the Macro coding that will calculate cell(s) in another file.
Can it be done if this other file is also on the computer screen?
Can it be done if this other file is not also on the computer screen?

If either or both can be done, what is the Macro codings?
Thankyou
Ed

Ronald Dodge

Referring to a worksheet in another file.
 
Syntax:

Dim I as Long
With Workbooks("Book1.xls")
For I = 1 to .Worksheets.Count Step 1
.Worksheets(I).Calculate
Next I
End With

Remarks:

The above code calculates each sheet one by one starting from the first
sheet to the last sheet. I also assumes that no worksheet is dependent on
some value of another worksheet later in the workbook, so if this isn't the
case, then the code would need to be modified to specify the order of the
worksheets to be calculated.

The other option to force a full calculation of everything would be the one
line code below:

Application.CalculateFullRebuild

Instead of the question being does it need to be on the computer screen, the
real question should be, "Does it need to be open?"

The workbook does need to be open within Excel, but it does not need to be
visible on the screen itself.

For more information on how to open workbooks via code, look at the Open
Method on the Workbooks Collection.

--
Ronald R. Dodge, Jr.
Production Statistician/Programmer
Master MOUS 2000

"Ed" wrote in message
...
Hi
I need the Macro coding that will calculate cell(s) in another file.
Can it be done if this other file is also on the computer screen?
Can it be done if this other file is not also on the computer screen?

If either or both can be done, what is the Macro codings?
Thankyou
Ed




Ed

Referring to a worksheet in another file.
 
Hi Ronald
Thankyou, you solved my problem.
Ed

"Ronald Dodge" wrote:

Syntax:

Dim I as Long
With Workbooks("Book1.xls")
For I = 1 to .Worksheets.Count Step 1
.Worksheets(I).Calculate
Next I
End With

Remarks:

The above code calculates each sheet one by one starting from the first
sheet to the last sheet. I also assumes that no worksheet is dependent on
some value of another worksheet later in the workbook, so if this isn't the
case, then the code would need to be modified to specify the order of the
worksheets to be calculated.

The other option to force a full calculation of everything would be the one
line code below:

Application.CalculateFullRebuild

Instead of the question being does it need to be on the computer screen, the
real question should be, "Does it need to be open?"

The workbook does need to be open within Excel, but it does not need to be
visible on the screen itself.

For more information on how to open workbooks via code, look at the Open
Method on the Workbooks Collection.

--
Ronald R. Dodge, Jr.
Production Statistician/Programmer
Master MOUS 2000

"Ed" wrote in message
...
Hi
I need the Macro coding that will calculate cell(s) in another file.
Can it be done if this other file is also on the computer screen?
Can it be done if this other file is not also on the computer screen?

If either or both can be done, what is the Macro codings?
Thankyou
Ed






All times are GMT +1. The time now is 09:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com