If you run a macro containing the following code when you have selected a range starting with the first question and ending with the last answer of the last question, it will randomize the answers.
Dim i As Long, J As Long, k As Long, n As Long
Dim Temp As Variant
Dim rngQuestions As Range
Dim rnganswers As Range
Dim rnganswer As Range
Dim ArrAnswers As Variant
Set rngQuestions = Selection.Range
With rngQuestions
For i = 2 To .Paragraphs.Count Step 5
Set rnganswers = .Paragraphs(i).Range
rnganswers.MoveEnd wdParagraph, 3
rnganswers.End = rnganswers.End - 1
ArrAnswers = Split(rnganswers.Text, vbCr)
Randomize
For n = LBound(ArrAnswers) To UBound(ArrAnswers)
J = CLng(((UBound(ArrAnswers) - n) * Rnd) + n)
If n <> J Then
Temp = ArrAnswers(n)
ArrAnswers(n) = ArrAnswers(J)
ArrAnswers(J) = Temp
End If
Next n
For k = LBound(ArrAnswers) To UBound(ArrAnswers)
Set rnganswer = rnganswers.Paragraphs(k + 1).Range
rnganswer.End = rnganswer.End - 1
rnganswer.Text = ArrAnswers(k)
Next k
Next i
End With
The range that is selected must be exactly as indicated above and nothing else. That is it must contain n questions and 4n answers with the first paragraph selected being the first question.
Hope this helps, Doug Robbins - MVP Office Apps & Services (Word) dougrobbinsmvp@gmail.com It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy
2 people found this reply helpful
·
Was this reply helpful?
Sorry this didn't help.
Great! Thanks for your feedback.
How satisfied are you with this reply?
Thanks for your feedback, it helps us improve the site.