Learn to make a PowerPoint Quiz Game using Trigger Animations....

**How to Shuffle PowerPoint Slides in a Random Order**

If you want all the slides of a particular range to occur without repetition in slide-show view, you can use the following VBA Macro which literally shuffles the selected slides in a random order.

```
Sub ShuffleSlides()
FirstSlide = 2
LastSlide = 7
Randomize
'generate random number between 2 to 7'
RSN = Int((LastSlide - FirstSlide + 1) * Rnd + FirstSlide)
For i = FirstSlide To LastSlide
ActivePresentation.Slides(i).MoveTo (RSN)
Next i
End Sub
```

Now if you would like to avoid repetition of slides i.e all slides viewed in a sequence have to be unique, you have to use the following code.

Normally, same random numbers can be generated, we fixed same random numbers being generated consecutively by using the GRN Loops above, however if I am in Slide 2 now and get redirected to Slide 6, I can again still be redirected to Slide 2. To be redirected to unique slides alone, we will use the following code:

## RND Function & Randomize Function in VBA

RND function in Visual Basic Application generates a random number of the data type *Single* which is **less than 1 but greater than or equal to 0.**

Remember to use the **Randomize** Function before using the RND Function. The **Randomize** Function makes the order of the random numbers generated random.

There are many sequences or orders to generate *pseudo-random* numbers via VBA which are called **seeds**.

For any given initial seed, the same number sequence is generated because each successive call to the **Rnd** function uses the previous number as a seed for the next number in the sequence.

Before calling **Rnd,** use the **Randomize** statement without an argument to initialize the random-number generator with a seed based on the system timer.

## Generate Random Number between a Range in VBA

`Int((upperbound - lowerbound + 1) * Rnd + lowerbound) `

Here, *upperbound* is the highest number in the range, and *lowerbound* is the lowest number in the range.

## Shuffle Only EVEN Numbered Slides in PowerPoint

```
Sub ShuffleSlidesEVEN()
FirstSlide = 1
LastSlide = 8
Randomize
For i = FirstSlide + 1 To LastSlide Step 2 'we are adding 1 to FirstSlide to make it even'
generate: 'generate random number between FirstSlide and LastSlide'
RSN = Int((LastSlide - FirstSlide + 1) * Rnd + FirstSlide)
If RSN Mod 2 = 1 Then GoTo generate
ActivePresentation.Slides(i).MoveTo (RSN)
If i < RSN Then ActivePresentation.Slides(RSN - 1).MoveTo (i)
If i > RSN Then ActivePresentation.Slides(RSN + 1).MoveTo (i)
Next i
End Sub
```

## Reverse the order of PowerPoint Slides

```
Sub ReverseSlideOrder()
For i = 2 To 5 '2 to 5 is the slide range'
ActivePresentation.Slides(5).MoveTo (i)
Next i
'This will reverse the order of slides
the 5th slide will become the 2nd
the 4th slide will become the 3rd...''
End Sub
```

## Shuffle Only ODD Numbered Slides in PowerPoint

```
Sub ShuffleSlidesODD()
FirstSlide = 1
LastSlide = 8
Randomize
For i = FirstSlide To LastSlide Step 2 'just make sure FirstSlide is Odd, incase FirstSlide = 2 then we would need to subtract 1 from it.''
generate: 'generate random number between FirstSlide and LastSlide'
RSN = Int((LastSlide - FirstSlide + 1) * Rnd + FirstSlide)
If RSN Mod 2 = 0 Then GoTo generate
ActivePresentation.Slides(i).MoveTo (RSN)
If i < RSN Then ActivePresentation.Slides(RSN - 1).MoveTo (i)
If i > RSN Then ActivePresentation.Slides(RSN + 1).MoveTo (i)
Next i
End Sub
```

## How to Shuffle PowerPoint Slides in a Random Order

If you want all the slides of a particular range...

## Populate A PowerPoint Quiz From Excel With VBA

Import Questions & Answers of a Microsoft PowerPoint Multiple-Choice Quiz...

## PowerPoint Educational Game – Free Classroom Chatbot

This PowerPoint Educational Game - Classroom Chatbot can ask questions...