PC Review


Reply
Thread Tools Rate Thread

calculating sheets

 
 
PH NEWS
Guest
Posts: n/a
 
      21st Feb 2006
Hi All,

I'm trying to calculate a certain selection of sheets all in one go, the
sheets I want to calculate change on a daily basis. Basically, I want to
pick, say, sheet1, sheet4, sheet7, etc, and then calculate them at the same
time.
I have ASAP on my machine and use the "print multiple sheets" function,
however the "calculate the sheets to be printed" button doesn't seem to
work.
Can anyone help?


 
Reply With Quote
 
 
 
 
vezerid
Guest
Posts: n/a
 
      21st Feb 2006
You can do this with VBA, my modifying the line below sh=Array(...)

Sub CalcSheets()
Dim sh As Variant
sh = Array("Sheet1", "Sheet2", "Sheet3")
For i = LBound(sh) To UBound(sh)
Sheets(sh(i)).Calculate
Next i
End Sub

To install:
Alt+F11 to go to the VBA IDE
Insert|Module
Paste the code above.

To run:
Alt+F8.
Choose CalcSheets
Or you can put a button on a worksheet. When you draw it, Excel will
ask you which macro to assign. Select this macro.

HTH
Kostis Vezerides

 
Reply With Quote
 
PH NEWS
Guest
Posts: n/a
 
      21st Feb 2006
Thank you, but won't I have to change the code each time the sheets I want
to calculate change? For example one week I may want to calculate sheets 3
and 6 and the next week I want to calculate sheets 2, 4, 7 and 10. Is there
a way a can select the relevant sheets and then calculate?


"vezerid" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You can do this with VBA, my modifying the line below sh=Array(...)
>
> Sub CalcSheets()
> Dim sh As Variant
> sh = Array("Sheet1", "Sheet2", "Sheet3")
> For i = LBound(sh) To UBound(sh)
> Sheets(sh(i)).Calculate
> Next i
> End Sub
>
> To install:
> Alt+F11 to go to the VBA IDE
> Insert|Module
> Paste the code above.
>
> To run:
> Alt+F8.
> Choose CalcSheets
> Or you can put a button on a worksheet. When you draw it, Excel will
> ask you which macro to assign. Select this macro.
>
> HTH
> Kostis Vezerides
>



 
Reply With Quote
 
vezerid
Guest
Posts: n/a
 
      21st Feb 2006
Create a new management sheet in the same workbook. Select a column,
say A:A, for this purpose. Use cells A1, A2, ... every week to write
the sheets to be calculated. My modified code assumes you will call
this sheet MGMT and that you will start your cells from column A:A.
Then use this variant:

Sub CalcSheets()
i = 1
While Sheets("MGMT").Cells(i, "A") <> ""
Sheets(Cells(i, "A")).Calculate
i = i + 1
Wend
End Sub

Any better?

Kostis Vezerides

 
Reply With Quote
 
vezerid
Guest
Posts: n/a
 
      21st Feb 2006
Sorry, one minor change, to avoid possible errors:

Sub CalcSheets()
i = 1
While Sheets("MGMT").Cells(i, "A") <> ""
Sheets(Sheets("MGMT").Cells(i, "A")).Calculate
i = i + 1
Wend
End Sub

 
Reply With Quote
 
PH NEWS
Guest
Posts: n/a
 
      22nd Feb 2006
It looks like that is exactly what I want, however I'm having problems
running it. When I click the run button there is an error message which says
Type Mismatch. Is there anything I can do?

SPL


"vezerid" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sorry, one minor change, to avoid possible errors:
>
> Sub CalcSheets()
> i = 1
> While Sheets("MGMT").Cells(i, "A") <> ""
> Sheets(Sheets("MGMT").Cells(i, "A")).Calculate
> i = i + 1
> Wend
> End Sub
>



 
Reply With Quote
 
vezerid
Guest
Posts: n/a
 
      25th Feb 2006
OK, it gave me the same error message, which I worked around with a
small modification. The following code does not create any error
messages:

Sub CalcSheets()
i = 1
While Sheets("MGMT").Cells(i, "A") <> ""
shname = Sheets("MGMT").Cells(i, "A")
Sheets(shname).Calculate
i = i + 1
Wend
End Sub

Let me know if all goes well

Kostis Vezerides

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calculating valuses from all sheets Deepak Microsoft Excel Misc 2 5th Aug 2008 09:20 PM
calculating sheets =?Utf-8?B?ZW55YXc=?= Microsoft Excel Misc 1 31st Aug 2006 10:03 AM
calculating from other sheets =?Utf-8?B?ZW55YXc=?= Microsoft Excel Programming 3 29th Aug 2006 12:05 PM
CALCULATING WORKSHEETS (INCLUDING AGE CALCULATING SHEETS) FOR DOWNLOADING, GREAT FOR PENSIONS/LIFE INSURANCE CALCULATIONS! RICHARD Microsoft Excel Programming 0 15th Mar 2005 01:41 PM
calculating 2 sheets question Genaveve Microsoft Excel Worksheet Functions 0 2nd Dec 2003 07:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:54 AM.