Power Point VBA code

mse330

Well-known Member
Joined
Oct 18, 2007
Messages
777
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am working on a presentation & I want to show a number that decreases (like a counter) & after looking on some YouTube videos I think it could be achieved much easier with the VBA loop. However, I am having an issue with the below code where it will start with 10 (in presentation mode) but will not show the number 9, 8, 7 … etc. but the screen will freezes until the loop ends & shows me 1 at the end. Any idea what am I doing wrong or how to achieve my goal ?


Code:
Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
For X = 10 To 1 Step -1
    ActivePresentation.Slides(1).Shapes("Rectangle 3").Fill.ForeColor.RGB = RGB((X * 10), (X * 10), (X * 10))
    ActivePresentation.Slides(1).Shapes("Rectangle 3").TextFrame2.TextRange.Characters.Text = X
    T = Timer
    Do While Timer - T < 0.5
    Loop
Next
End Sub
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
I suggest you look at the timer bit
T=timer then you test timer-to which would have the same values giving an almost zero result so while loop will never execute
Have you looked at the wait function
 
Upvote 0
Thank you jimrward for your reply. I have developed the some code in excel & it is working as intended. The reason I use timer & not wait function is I don't want to wait 1 second for a number in the loop, I want it to be a bit faster

Code:
Sub Count_Down()
For X = 10 To 1 Step -1
    With Cells(1, 1)
        .Font.Color = vbWhite
        .Interior.Color = RGB((X * 10), (X * 10), (X * 10))
        .Value = X
    End With
    T = Timer
    Do While Timer - T < 0.5
    Loop
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top