View Single Post
  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default 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