Auto recalculate?

  • Thread starter Thread starter Lee Harris
  • Start date Start date
L

Lee Harris

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top