Function Problems

How to Generate Random Quiz Questions with a Per-Topic Limit in Excel

Adam DavisAdam Davis Nov 10, 2026 868 views

Question details

The user needs to create a formula-based quiz generator that selects 30 random questions from a larger pool, with the condition that no more than two questions are chosen from any single topic.

How to Generate Random Quiz Questions with a Per-Topic Limit in Excel
Product
Excel
Device & OS
not provided
Scenario
Creating a randomized, balanced test from a comprehensive master list of questions covering multiple topics.
Observed behavior
The goal is to consolidate multiple topics into one source table and use functions to automatically randomize, sort, and limit the output to the desired question count.
Before you start

Consolidate all your questions and their corresponding topics into a single master Excel table with a 'Question' and 'Topic' column, rather than keeping them spread across multiple worksheets.

Solution 1Recommended

Use Dynamic Array Functions (SORTBY and FILTER)

Leverage modern dynamic array formulas in Microsoft 365 to instantly sort your question pool randomly and filter the desired number of questions per topic.

This approach uses Excel's powerful dynamic arrays to randomize data without manually sorting columns every time you want a new quiz.

1
Set up your master table

Ensure your master data is formatted as an Excel Table with headers like 'Question' and 'Topic'.

2
Add a random helper column

Create a new column in your table named 'Random' and enter the formula `=RAND()` to assign a random decimal value to every question.

3
Randomize the question pool

In a new cell outside the table, use the `=SORTBY(Table1, Table1[Random])` formula to output the entire list of questions in a completely random order.

4
Filter to limit topics

Combine this with the FILTER and TAKE functions, or use a COUNTIFS formula alongside your random list, to extract only the first two occurrences of each topic until you reach exactly 30 questions.

Use Dynamic Array Functions (SORTBY and FILTER)
Recalculation: Because the RAND function is volatile, you can generate a brand new quiz simply by pressing the F9 key to recalculate the workbook.
Smart Spreadsheet Management

Effortlessly Generate Random Quizzes with WPS Spreadsheet

WPS Spreadsheet provides robust support for advanced formulas including RAND, SORTBY, and COUNTIFS, making it simple to build dynamic quiz generators in a fast, familiar interface.

  1. 1. Launch WPS Spreadsheet: Open WPS Office and create or import your master question document.
  2. 2. Apply random generation: Type `=RAND()` into a new helper column to assign random numbers to your question pool.
  3. 3. Sort the dataset: Use the built-in Data sorting tools to shuffle the rows based on the random helper column.
  4. 4. Generate new versions: Press F9 to instantly recalculate the RAND formulas, giving you a fresh set of randomized questions on demand.
Fully compatible with Microsoft Excel formulas and functionsSeamlessly handles large datasets and complex running calculationsFamiliar user interface requiring zero learning curveFree and lightweight alternative to heavy office suites
microsoft office alternative - wps office

Frequently Asked Questions

Why are my selected questions changing when I type in another cell?

The =RAND() formula is a volatile function, meaning it recalculates every time any change is made to the worksheet. To freeze your quiz once generated, select the 30 questions, copy them, and use 'Paste as Values' to remove the formulas.

Can I use multiple worksheets for different quiz topics?

While it is technically possible using complex macros or Power Query, it is highly recommended to combine all questions into a single table with a 'Topic' column. A single source table is significantly easier to manage, sort, and filter using standard formulas.

How do I instantly generate a new 30-question quiz?

If you have set up your generator using the =RAND() function, simply press the F9 key on your keyboard. This forces Excel to recalculate all formulas, instantly shuffling the questions and pulling a new set.