ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Auto recalculate? (https://www.excelbanter.com/excel-worksheet-functions/55034-auto-recalculate.html)

Lee Harris

Auto recalculate?
 
I have a nifty sheet that does some automated play calling for a game, and
it works fine if I just select a cell (empty one) and hit delete - it
re-randomises and picks a play

however, I tried adding a button and code to make it a clickable button, but
it doesn't seem to work. In addition, I cannot even remember how I added the
button or code (I got into VBA with Alt-F11 but am not sure how I linked the
code to the button, or whether somethings gone wrong)

I have other files with the same clickable button and exactly the same code
and it works fine.

If possible I would also like to be able to have a button on a separate tab
in the same file also randomising everything via the same recalculate method
if I can do that..

any help greatly appreciated. Can send file too if you like, only 53 KB
zipped up.


Private Sub CommandButton1_Click()
Calculate
End Sub



Tim C

Auto recalculate?
 
Try F9.

Tim C

"Lee Harris" wrote in message
...
I have a nifty sheet that does some automated play calling for a game, and
it works fine if I just select a cell (empty one) and hit delete - it
re-randomises and picks a play

however, I tried adding a button and code to make it a clickable button,
but it doesn't seem to work. In addition, I cannot even remember how I
added the button or code (I got into VBA with Alt-F11 but am not sure how
I linked the code to the button, or whether somethings gone wrong)

I have other files with the same clickable button and exactly the same
code and it works fine.

If possible I would also like to be able to have a button on a separate
tab in the same file also randomising everything via the same recalculate
method if I can do that..

any help greatly appreciated. Can send file too if you like, only 53 KB
zipped up.


Private Sub CommandButton1_Click()
Calculate
End Sub




Lee Harris

Auto recalculate?
 

"Tim C" wrote in message
...
Try F9.

Tim C


what does F9 do? I need it to be a button because I'm sending this sheet to
someone else and want it to look nice.



"Lee Harris" wrote in message
...
I have a nifty sheet that does some automated play calling for a game, and
it works fine if I just select a cell (empty one) and hit delete - it
re-randomises and picks a play

however, I tried adding a button and code to make it a clickable button,
but it doesn't seem to work. In addition, I cannot even remember how I
added the button or code (I got into VBA with Alt-F11 but am not sure how
I linked the code to the button, or whether somethings gone wrong)

I have other files with the same clickable button and exactly the same
code and it works fine.

If possible I would also like to be able to have a button on a separate
tab in the same file also randomising everything via the same recalculate
method if I can do that..

any help greatly appreciated. Can send file too if you like, only 53 KB
zipped up.


Private Sub CommandButton1_Click()
Calculate
End Sub






Dave Peterson

Auto recalculate?
 
Try:

Option Explicit
Private Sub CommandButton1_Click()
Application.Calculate
End Sub

Since the code is under the worksheet and Calculate is not qualified by
anything, excel assumes you want just that worksheet calcuated.

The same as typing:
worksheets("sheet1").calculate
or behind the worksheet:
me.calculate



Lee Harris wrote:

I have a nifty sheet that does some automated play calling for a game, and
it works fine if I just select a cell (empty one) and hit delete - it
re-randomises and picks a play

however, I tried adding a button and code to make it a clickable button, but
it doesn't seem to work. In addition, I cannot even remember how I added the
button or code (I got into VBA with Alt-F11 but am not sure how I linked the
code to the button, or whether somethings gone wrong)

I have other files with the same clickable button and exactly the same code
and it works fine.

If possible I would also like to be able to have a button on a separate tab
in the same file also randomising everything via the same recalculate method
if I can do that..

any help greatly appreciated. Can send file too if you like, only 53 KB
zipped up.

Private Sub CommandButton1_Click()
Calculate
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 02:22 AM.

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