How to Shuffle Slides in RANDOM Order in PowerPoint - PPT VBA Tutorial

preview_player
Показать описание

--------------------------------------------------------------------------
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
--------------------------------------------------------------------------

*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.

*Generating a random integer between a given 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.

--

Music by Ashwin Subrahm and Distant Lakey Inspired

I also do freelancing, contact me:
Bhavesh Shaha,

Рекомендации по теме
Комментарии
Автор

If you liked the tutorial! Hit the like button for the YouTube Algorithm :) Thank you.

PPTVBA
Автор

dear
Bhavesh Shaha, I really want to thank you for your time and educational video for the support of many. I am sure many people will not even say thank you, but here I want you to know I am really grateful for your help. Merry Christmas to you and your whole family.

ブラガアンドレ
Автор

Thank you so much for sharing. I'm a language teacher and planning on using this to play bingo with some irregular verbs. Greetings from Mexico City!.

EveraldoReyesGalicia
Автор

This was SO helpful for my classroom! Thank you very much for creating this detailed video for teachers like me :)!

kimberleythorn
Автор

This is amazing, I looked all over for this and none of the codes worked how I needed them to. Thank you SO much!

alexisaustin
Автор

I'm a teacher and this was super helpful! Thank you!!

shelleylevin
Автор

It helped me a lot. Thank you. I just logined Google for making this comment. You are the best.

arabo
Автор

Thank you, i will use this to randomize flashcard quiz for online class, great video

adamrazzor
Автор

Thank you for this very nice explanation. I like how well explained it is. The stepwise code explanation is very clear.

felixolasagasti
Автор

Nice one! Worked brilliantly:)
I used this to make a bingo game for special needs students. I saved it as macro enabled show so that it loads without seeing the order of slides.
I just copied your code and changed 7 for 16 (in my case)

Sub ShuffleSlides()
FirstSlide = 2
LastSlide = 16

Randomize
'generate random number between 2 to 16'
RSN = Int((LastSlide - FirstSlide + 1) * Rnd + FirstSlide)

For i = FirstSlide To LastSlide
(RSN)
Next i
End Sub

marcjenkins
Автор

Thanks for educating! Really helpful. I wanna to ask, is there possible to use percentage rate on each slide rather than pure random? Thank you

musicavionikaltdas
Автор

This was SO helpful!! I am so excited to use this. Thank you so much!!

sunggyuhyung
Автор

Very helpful! Thank you! How would you edit the code to reverse the order of all the slides (instead of making them random)?

bonusresults
Автор

Nice short tutorial...Very clear explanation...Thanks very much. Cheers!

zorrog.
Автор

This is really helpful when i use this as a flashcard to learning new language. Totally awesome

hoangphunguyen
Автор

This was REALLY helpful! Thank you so much!

StaceyMyers
Автор

Thank you, Mr. Shaha. That's very helpful. But I have a question. How to go to a random slide (one after another) continuously but with no slides shown earlier shown again. Simply put, is there a marco that allows us to go to a random slide with no duplication? Is this possible? You mentioned in this video that there's a way to realise that and you said you would show how to do it in another video, but I checked your channel for it, and I couldn't find it myself. Would it be possible that you could tell me how to do that? I need this function for my PPT game. LOL

kenchiang
Автор

Excellent. It is entirely different from Tech Train. Good Night.

ABSBOnline
Автор

Super helpfull man thank you so much, i know nothing about coding so this is perfect, just a question how do you save this so you can also save the macro so i can send the ppt to my friends as wel :)

laurentvds
Автор

You're my hero, man. Thank you! :)))

tomasdve