View Full Version : Create random slide number (2 to x) and keep the same throughout the show.
Fred.Peters
10-26-2020, 12:54 PM
I want to generate a random number from 4 to x, (x being the number of slides in the show) on the first slide and keep that variable unchanged throughtout thewhole show.
In a previous post I dont think i explained it right and presented code that was full of errors. I can generate the numbers but cannot keep them throughout the slideshow.
Windows 10 Home
Powerpoint 19
Any advise or solution would be greatly appreciated.
Fred
John Wilson
10-27-2020, 07:29 AM
Try this Note you said 2 - x and 4-x change low_range to suit
Dim lngRand As Long ' declare outside sub
Sub makernd()
Dim high_range As Long
Dim low_range As Long
low_range = 2
high_range = ActivePresentation.Slides.Count
Randomize
lngRand = Int((high_range - (low_range - 1)) * Rnd) + low_range
End Sub
John Wilson
10-27-2020, 07:39 AM
Try this Note you said 2 - x and 4-x change low_range to suit
Dim lngRand As Long ' declare outside sub
Sub makernd()
Dim high_range As Long
Dim low_range As Long
low_range = 2
high_range = ActivePresentation.Slides.Count
Randomize
lngRand = Int((high_range - (low_range - 1)) * Rnd) + low_range
End Sub
Sorry posted twice slip of finger!
Fred.Peters
10-27-2020, 07:48 PM
Thank you John. I remained with my code, but used your dim outside the sub and got my desired results. I had thought I tried that before but this time it worked!!! THANK YOU!!
:hi:
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.