Storing Results of a Dice Roll

Simonc64

Active Member
Joined
Feb 15, 2007
Messages
251
Office Version
  1. 365
Hi Guys

Hope this is possible. I have a neat little single dice roll set up, but now that is working, I want to "store" the results of each roll in consecutive cells.

So, dice roll 1 scores a 5 store in cell G1
dice roll 2 scores a 3 store in cell G2
dice roll 3 scores a 1 store in cell G3

and so on.............

So not only do i need to store the result so that it doesn't change on every dice roll, I need to put each subsequent "roll" into a new cell

Hope you can help!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi Guys

Hope this is possible. I have a neat little single dice roll set up, but now that is working, I want to "store" the results of each roll in consecutive cells.

So, dice roll 1 scores a 5 store in cell G1
dice roll 2 scores a 3 store in cell G2
dice roll 3 scores a 1 store in cell G3

and so on.............

So not only do i need to store the result so that it doesn't change on every dice roll, I need to put each subsequent "roll" into a new cell
You will need to use a VBA macro to do that...
Code:
Sub RollDie()
  Cells(Rows.Count, "G").End(xlUp).Offset(1) = [RANDBETWEEN(1,6)]
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (RollDie) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

To make things simpler for you (especially if you will need to call this macro often), when you select the macro from the list, before clicking Run, you can click the Options button and assign a keyboard shortcut to it first and then use that keyboard shortcut the next time you want to run the macro. Alternately, you can assign this macro to a Form Control Button so that you can just click it in order to run the macro.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top