Random Number Generator

anasshaukat

New Member
Joined
Mar 9, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,
I am creating a math game in excel, and i wanted to use a random number generator to randomize the questions. I also made it when they get the correct answer the box is green and if it isnt its red. However whenever I type the answer in, it randomizes the questions again before you can answer it correctly. I want it to wait until its correct, protect the sheet, and then make a button show up that says next question, where when I click it the button disappears and a new equation appears. Hope this is not too confusing.

P.S Idk where to learn Macro from so its hard for me so I hoped the community could help me. Thanks.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
hi and welcome to MrExcel
it will help if you post your code
 
Upvote 0
Screenshot 2021-03-09 214247.png
hohope
Screenshot 2021-03-09 214108.png
Screenshot 2021-03-09 214042.png
Hope this helps. I am slightly new to VBA so dont quite know how it works. The button is supposed to make the numbers randomized and it does that, but when I randomize the questions, and try to type in the correct answer, it changes it to a new equation.
 
Upvote 0
when you press the Button2 is that when the macro4 runs
are there any other macros
 
Upvote 0
No there isnt any other macros besides that one. And yes when i press the button the macro runs. Thank you in advance for helping. I'm so bad at excel?
 
Upvote 0
put this new line before your line as i have shown. that may sort your problem

VBA Code:
Range("BU13").Value=""
Range("BI18").Select
 
Upvote 0
Thanks. It did solve half my problem though. Do you know how to make the randomizer not randomize the 2 cells when I type in an answer?
 
Upvote 0
i would generate the random numbers in the code...
VBA Code:
Sub Macro4()
    Range("P13").Value = Int(Rnd()*10 +1)
    Range("AY13").Value = Int(Rnd()*10 +1)
    Range("BU13").Value=""
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,948
Messages
6,175,567
Members
452,652
Latest member
eduedu

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