Is possible to shuffle answers in multiple choice test in EXCEL?

t0m1noo

New Member
Joined
Apr 17, 2020
Messages
7
Office Version
  1. 2019
Platform
  1. Windows
I have a lot of questions and I need to quickly shuffle answers in Multiple Choice Test. (1 question has 4 answers, A,B,C, or D).
For example:
example1.png

Is possible to do that by using VBA or with some formula?

Thanks for the help.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
It may require some preparation and set-up, but do-able like this:
1. random using RAND()
2. rank to enable the lookup
3. lookup the rank in the final table
4. F9 will update the rank each time
Book1
ABCDEFG
1Question 1randomrankQuestion 1
2a correct0,59091121c correct
3b false0,12075542a correct
4c correct0,81406513d false
5d false0,22713634b false
6Question 2Question 2
7a false0,15575131d false
8b correct0,31192722b correct
9c false0,089343a false
10d false0,48770814c false
11Question 3Question 3
12a correct0,60601131c false
13b correct0,11226642d correct
14c false0,93369713a correct
15d correct0,92768524b correct
Sheet1
Cell Formulas
RangeFormula
B12:B15,B7:B10,B2:B5B2=RAND()
C2:C5C2=RANK.EQ(B2,$B$2:$B$5,0)
G2:G5G2=INDEX($A$2:$A$5,MATCH(F2,$C$2:$C$5,0))
C7:C10C7=RANK.EQ(B7,$B$7:$B$10,0)
G7:G10G7=INDEX($A$7:$A$10,MATCH(F7,$C$7:$C$10,0))
C12:C15C12=RANK.EQ(B12,$B$12:$B$15,0)
G12:G15G12=INDEX($A$12:$A$15,MATCH(F12,$C$12:$C$15,0))
 
Upvote 0
Thank you very much. Is it applicable for 500 questions at once? Or do I have to do it manually?
 
Upvote 0
Like I said, requires some set-up and preparation. Doing this took me like 3 minutes (not even, but to give an idea).
Cell Formulas
RangeFormula
B7:R10B7=RAND()
B12:R15B12=RANK(B7,B$7:B$10,0)
B17:R20B17=INDEX(B$2:B$5,MATCH(B12,$A$17:$A$20,0))
 
Upvote 0
Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!


Cross posted at: Is possible to shuffle answers in multiple choice test in EXCEL?
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Like I said, requires some set-up and preparation. Doing this took me like 3 minutes (not even, but to give an idea).
Cell Formulas
RangeFormula
B7:R10B7=RAND()
B12:R15B12=RANK(B7,B$7:B$10,0)
B17:R20B17=INDEX(B$2:B$5,MATCH(B12,$A$17:$A$20,0))

Thanks. I like the first idea. I really appreciate your effort to help me. But I don't know how to apply it for bigger amount of question. I have just basic skills in Excel, so that's why I am not able to do a lot of sets-up and preparation.
 
Upvote 0
Try the below macro considering you only have 4 answers per question & they're in column A and shuffled questions will be pasted in column C with the same format you've posted in the attached picture in post #1

VBA Code:
Sub ShuffleQuestions()

Dim a As Variant, b As Variant, Ans(1 To 4) As String, Coll As New Collection
a = ActiveSheet.Range("A1").CurrentRegion

ReDim b(1 To UBound(a))
For x = LBound(a) To UBound(a)
    If a(x, 1) Like "*uestion*" Then
        b(x) = a(x, 1)
    ElseIf a(x, 1) Like "a)*" Then
        For y = 0 To 3
            Coll.Add y + 1
            Ans(y + 1) = a(x + y, 1)
        Next
        For y = 0 To 3
            j = WorksheetFunction.RandBetween(1, Coll.Count)
            b(x + y) = Ans(Coll(j))
            Coll.Remove j
        Next
    End If
Next x

ActiveSheet.Range("C1").Resize(UBound(b)) = Application.Transpose(b)

End Sub
 
Upvote 0
Thanks. I like the first idea. I really appreciate your effort to help me. But I don't know how to apply it for bigger amount of question. I have just basic skills in Excel, so that's why I am not able to do a lot of sets-up and preparation.
Simply add more Q&A's at the end and drag the formula to the right. That should be do-able even with limited excel knowledge.
 
Upvote 0
Try the below macro considering you only have 4 answers per question & they're in column A and shuffled questions will be pasted in column C with the same format you've posted in the attached picture in post #1

VBA Code:
Sub ShuffleQuestions()

Dim a As Variant, b As Variant, Ans(1 To 4) As String, Coll As New Collection
a = ActiveSheet.Range("A1").CurrentRegion

ReDim b(1 To UBound(a))
For x = LBound(a) To UBound(a)
    If a(x, 1) Like "*uestion*" Then
        b(x) = a(x, 1)
    ElseIf a(x, 1) Like "a)*" Then
        For y = 0 To 3
            Coll.Add y + 1
            Ans(y + 1) = a(x + y, 1)
        Next
        For y = 0 To 3
            j = WorksheetFunction.RandBetween(1, Coll.Count)
            b(x + y) = Ans(Coll(j))
            Coll.Remove j
        Next
    End If
Next x

ActiveSheet.Range("C1").Resize(UBound(b)) = Application.Transpose(b)

End Sub

Thank you! This macro works perfectly. Is possible to modify this macro in order to there were also questions in column C instead of empty cells?
 
Upvote 0
You can simply change the location of the data from column C to any other by changing C1 in the last line of code to D1 or E2 ... etc.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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