Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 14
There are 1 users currently browsing forums.
|
 |

07-04-2009, 03:20 PM
|
|
Registered User
|
|
Join Date: 07 May 2009
Location: Chesham,England
MS Office Version:Excel 2003 (11.5612.5606)
Posts: 28
|
|
|
Calculate Button
Please Register to Remove these Ads
Hello I am trying to create a Radio button in a cell that calculates the entire workbook rather than pressing F9.
I am not friendly with macro's yet so would prefer not to use any but I must learn....
Cheers
Martyn
|

07-04-2009, 03:31 PM
|
 |
Forum Guru
|
|
Join Date: 21 Jun 2007
Location: The Great State of Texas
MS Office Version:2003, 2007
Posts: 17,874
|
|
|
Re: Calculate Button
Create an AutoShape or Forms button, and assign this macro:
Code:
Sub Calc()
Calculate
End Sub
__________________
Entia non sunt multiplicanda sine necessitate.
|

07-04-2009, 03:39 PM
|
 |
Forum Guru
|
|
Join Date: 21 Mar 2008
Location: Bakersfield, CA
MS Office Version:2003 (can read 2007 files)
Posts: 8,415
|
|
|
Re: Calculate Button
I can't fathom how creating and coding a special button is better than just pressing F9. There is always the moment when we all "need to learn them", as you say, but I don't see how this qualifies.
Anyway. Simplest:
1) Turn on the Control Toolbox Toolbar
2) Click on Command Button icon
3) Draw your button on your sheet somewhere (it will appear with a name like CommandButton1)
4) Right click on your new button and select Properties
5) Find the Caption and change "CommandButton1" to "Calculate"
6) Set your Font choice and BackColor choice
7) Set TakeFocusOnClick to False (this will keep your activecell focus where it is, even when you click the button)
8) Close the Properties window
9) Right-click the button and select VIEW CODE, a VBA window will appear with header/footer for your command button already there, but no code in between, add the word Calculate in between.
Code:
Private Sub CommandButton1_Click()
Calculate
End Sub
10) Press ALT-Q to close the VBEditor.
11) Save your sheet.
12) On the Control Toolbox toolbar, click on the EXIT DESIGN MODE button
Your button is now active. Click your button to calculate the workbook.
__________________
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
“None of us is as good as all of us” - Ray Kroc Always put your code between [code] and [/code] tags.
|

07-04-2009, 03:55 PM
|
|
Registered User
|
|
Join Date: 07 May 2009
Location: Chesham,England
MS Office Version:Excel 2003 (11.5612.5606)
Posts: 28
|
|
|
Re: Calculate Button
Hi Thank you very much.
As for the reasoning I am writing a program, and I have created a data entry sheet I wanted the button as not all the program users will know that F9 is calculate and on auto calculate all the result cell's have Divide by 0 errors.
|

07-04-2009, 08:28 PM
|
 |
Forum Guru
|
|
Join Date: 21 Mar 2008
Location: Bakersfield, CA
MS Office Version:2003 (can read 2007 files)
Posts: 8,415
|
|
|
Re: Calculate Button
Quote:
Originally Posted by martynduerden
As for the reasoning I am writing a program, and I have created a data entry sheet I wanted the button as not all the program users will know that F9 is calculate
|
1) A note on the sheet "Press F9 to calculate" pretty much educates new users.
Quote:
|
...and on auto calculate all the result cell's have Divide by 0 errors.
|
2) Any formula that divides by a cell that could be empty should be rewritten. If the formula =A1/B1 gives an error when B1 is empty, evaluate cell B1 first....like so:
=IF(B1=0,"",A1/B1)
That technique can be adapted to solve most equations that result in errors when data is missing. It's a habit worth getting into and is far more useful than turning off calculations and hope you/others remember to update by pressing F9 or a button.
My two cents.
__________________
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
“None of us is as good as all of us” - Ray Kroc Always put your code between [code] and [/code] tags.
|

07-04-2009, 08:35 PM
|
|
Registered User
|
|
Join Date: 07 May 2009
Location: Chesham,England
MS Office Version:Excel 2003 (11.5612.5606)
Posts: 28
|
|
|
Re: Calculate Button
Hi,
I do intend to clean up the missing data errors but at the moment I am concentrating on getting the program working which is now seriously complex,
Currently the program occupies 61 sheets to produce the required data.
Cheers for all the help it is very much appreciated!
|

07-04-2009, 08:39 PM
|
 |
Forum Guru
|
|
Join Date: 21 Jun 2007
Location: The Great State of Texas
MS Office Version:2003, 2007
Posts: 17,874
|
|
|
Re: Calculate Button
Quote:
|
Currently the program occupies 61 sheets to produce the required data.
|
That seems extraordinarily complex for anything short of designing nuclear weapons.
__________________
Entia non sunt multiplicanda sine necessitate.
|

07-04-2009, 08:48 PM
|
|
Registered User
|
|
Join Date: 07 May 2009
Location: Chesham,England
MS Office Version:Excel 2003 (11.5612.5606)
Posts: 28
|
|
|
Re: Calculate Button
Quote:
Originally Posted by shg
That seems extraordinarily complex for anything short of designing nuclear weapons.
|
You should try being an electrician for a day!
|

07-05-2009, 02:18 PM
|
 |
Forum Guru
|
|
Join Date: 21 Mar 2008
Location: Bakersfield, CA
MS Office Version:2003 (can read 2007 files)
Posts: 8,415
|
|
|
Re: Calculate Button
If that takes care of your need, be sure to EDIT your original post, click on GO ADVANCED and set the PREFIX box to [Solved].
__________________
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
“None of us is as good as all of us” - Ray Kroc Always put your code between [code] and [/code] tags.
|

08-17-2009, 12:06 AM
|
|
Registered User
|
|
Join Date: 21 Jun 2009
Location: Sydney
MS Office Version:Excel 2003
Posts: 7
|
|
|
Re: Calculate Button
Quote:
Originally Posted by shg
Create an AutoShape or Forms button, and assign this macro:
Code:
Sub Calc()
Calculate
End Sub
|
Is there a code to do a calculate for just that sheet, ie. Shift + F9 ?
|

08-17-2009, 12:38 AM
|
|
Registered User
|
|
Join Date: 16 Aug 2009
Location: Fort Smith, AR
MS Office Version:Excel 2003
Posts: 14
|
|
|
Re: Calculate Button
Quote:
|
Is there a code to do a calculate for just that sheet, ie. Shift + F9 ?
|
Code:
worksheet("Myworksheet").calculate
|

08-17-2009, 02:34 AM
|
|
Registered User
|
|
Join Date: 21 Jun 2009
Location: Sydney
MS Office Version:Excel 2003
Posts: 7
|
|
|
Re: Calculate Button
Wonderful, many thanks !!!
|

08-17-2009, 07:07 AM
|
|
Registered User
|
|
Join Date: 21 Jun 2009
Location: Sydney
MS Office Version:Excel 2003
Posts: 7
|
|
|
Re: Calculate Button
Quote:
Originally Posted by shua79
Code:
worksheet("Myworksheet").calculate
|
I got the following error:
"Compile error:
Sub or Function not defined"
This is the section of the code:
ActiveSheet.Paste
Worksheet("Expenses Input").Calculate
Application.Run "'BUDGET.xls'!GO_Staff"
EDIT
Would this do the same thing?
ActiveSheet.Calculate
|

08-17-2009, 11:58 AM
|
 |
Forum Guru
|
|
Join Date: 21 Mar 2008
Location: Bakersfield, CA
MS Office Version:2003 (can read 2007 files)
Posts: 8,415
|
|
|
Re: Calculate Button
Two things:
Code:
Worksheets("Sheet2").Calculate
Notice thats plural, worksheets.
Second, the line of code
Code:
ActiveSheet.Paste
...implies you may be using .Select a bit in your code. Don't do that.
One thing that has to be done is code you learn how to write using the macro recorder (which I still use most days) needs to be cleaned up afterward to remove all the unnecessary selecting. Post up your entire macro and we can make some suggestions.
__________________
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
“None of us is as good as all of us” - Ray Kroc Always put your code between [code] and [/code] tags.
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|