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

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
hi and welcome to MrExcel
it will help if you post your code
 

anasshaukat

New Member
Joined
Mar 9, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
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.
 

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
when you press the Button2 is that when the macro4 runs
are there any other macros
 

anasshaukat

New Member
Joined
Mar 9, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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😓
 

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
put this new line before your line as i have shown. that may sort your problem

VBA Code:
Range("BU13").Value=""
Range("BI18").Select
 

anasshaukat

New Member
Joined
Mar 9, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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?
 

diddi

Well-known Member
Joined
May 20, 2004
Messages
3,337
Office Version
  1. 2010
Platform
  1. Windows
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
 
Solution

Forum statistics

Threads
1,147,498
Messages
5,741,504
Members
423,663
Latest member
kaveh87rsh

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
Top