filmov
tv
How to Shuffle Slides in RANDOM Order in PowerPoint - PPT VBA Tutorial
Показать описание
--------------------------------------------------------------------------
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,
Комментарии