Hey there...Thanks that is spot on. cause i have created a virtual business
where you control,buy and sell stock and run a business. The trick here is to
see how long you can run without getting bancrupt. You can also buy personal
things and so on...
however to play this I had to replace real dies with excell type formulas
and macros
thanks again.
"Nayab" wrote:
On Jun 20, 2:41 pm, Markv wrote:
thanks Mate, do you know the VB code for this. I have never used this type
programming
"Nayab" wrote:
On Jun 20, 12:15 pm, Markv wrote:
Hi all.
Does anyone have the formula to create a button on your work sheet that upon
clicking on it will give you a result?
ie. dice rolls, I would click on the button and the dice will roll.
Thanks.
Mark, button can be made but only button can't make things roll. U can
internally rite some vb code/macro to make things happen and then u
need to attach the click of this button to this macro. Otherwise u can
insert control buttons and on click of these buttons u can write the
corresponding code- Hide quoted text -
- Show quoted text -
Mark, I am not sure what exactly is ur requirement. Do you want to
display randomly picked values between 1,6 when you click a button?
If this is the case then, choose control toolbox and select the button
and draw it on the worksheet. Right click on this button and slect
view code.
On the code page, u see::::
Private Sub CommandButton1_Click()
End Sub
Change this to::::::::::::::::::
Private Sub CommandButton1_Click()
Dim rand_dice As Double
rand_dice = Rnd()
If rand_dice < 1 / 6 Then
rand_dice = 1
ElseIf rand_dice < 2 / 6 Then
rand_dice = 2
ElseIf rand_dice < 3 / 6 Then
rand_dice = 3
ElseIf rand_dice < 4 / 6 Then
rand_dice = 4
ElseIf rand_dice < 5 / 6 Then
rand_dice = 5
Else
rand_dice = 6
End If
MsgBox rand_dice
End Sub