ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping at regular interval (https://www.excelbanter.com/excel-programming/351457-looping-regular-interval.html)

grime[_17_]

looping at regular interval
 

I am trying to create a "marquee" effect by looping through 3 fill
effects.

It does what I'm going after, but only performs the fill effects once,
then stops. I am trying to get it to repeat from the beginning after
the 3rd fill effect.


Code:
--------------------
Dim iCount As Integer
Sub ColorChange()
Dim dTime As Date
dTime = Now
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange"
iCount = iCount + 1
If iCount = 1 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 2 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 3 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 13
End If
If iCount = 3 Then
iCount = 0
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange", , False
End If
End Sub
--------------------


Thank you in advance


--
grime
------------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504978


Tom Ogilvy

looping at regular interval
 
remove the line that cancels the Ontime (move it to another routine). Make
dtime a public variable or you won't be able to stop it without closing
Excel.

--
Regards,
Tom Ogilvy


"grime" wrote in
message ...

I am trying to create a "marquee" effect by looping through 3 fill
effects.

It does what I'm going after, but only performs the fill effects once,
then stops. I am trying to get it to repeat from the beginning after
the 3rd fill effect.


Code:
--------------------
Dim iCount As Integer
Sub ColorChange()
Dim dTime As Date
dTime = Now
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange"
iCount = iCount + 1
If iCount = 1 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 2 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 3 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 13
End If
If iCount = 3 Then
iCount = 0
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange", , False
End If
End Sub
--------------------


Thank you in advance


--
grime
------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504978




grime[_18_]

looping at regular interval
 

I'm fairly new to the VBA thing. Can you explain that? :confused:

Tom Ogilvy Wrote:
remove the line that cancels the Ontime (move it to another routine).
Make
dtime a public variable or you won't be able to stop it without
closing
Excel.

--
Regards,
Tom Ogilvy


"grime" wrote in
message ...

I am trying to create a "marquee" effect by looping through 3 fill
effects.

It does what I'm going after, but only performs the fill effects

once,
then stops. I am trying to get it to repeat from the beginning

after
the 3rd fill effect.


Code:
--------------------
Dim iCount As Integer
Sub ColorChange()
Dim dTime As Date
dTime = Now
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange"
iCount = iCount + 1
If iCount = 1 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 2 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 3 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 13
End If
If iCount = 3 Then
iCount = 0
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange", ,

False
End If
End Sub
--------------------


Thank you in advance


--
grime

------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread:

http://www.excelforum.com/showthread...hreadid=504978



--
grime
------------------------------------------------------------------------
grime's Profile: http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504978


Tom Ogilvy

looping at regular interval
 
Dim iCount As Integer
Dim dTime as Date
Sub ColorChange()
dTime = Now
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange"
iCount = iCount + 1
If iCount = 1 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 2 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 3 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 13
End If
If iCount = 3 Then
iCount = 0
End If
End Sub

Sub StopAnimation()
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange", , False
End Sub

--
Regards,
Tom Ogilvy


"grime" wrote in
message ...

I'm fairly new to the VBA thing. Can you explain that? :confused:

Tom Ogilvy Wrote:
remove the line that cancels the Ontime (move it to another routine).
Make
dtime a public variable or you won't be able to stop it without
closing
Excel.

--
Regards,
Tom Ogilvy


"grime" wrote in
message ...

I am trying to create a "marquee" effect by looping through 3 fill
effects.

It does what I'm going after, but only performs the fill effects

once,
then stops. I am trying to get it to repeat from the beginning

after
the 3rd fill effect.


Code:
--------------------
Dim iCount As Integer
Sub ColorChange()
Dim dTime As Date
dTime = Now
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange"
iCount = iCount + 1
If iCount = 1 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 2 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 13
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 8
End If
If iCount = 3 Then
ActiveSheet.Shapes("Group 1").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 2").Fill.ForeColor.SchemeColor = 8
ActiveSheet.Shapes("Group 3").Fill.ForeColor.SchemeColor = 13
End If
If iCount = 3 Then
iCount = 0
Application.OnTime dTime + TimeValue("00:00:01"), "ColorChange", ,

False
End If
End Sub
--------------------


Thank you in advance


--
grime

------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread:

http://www.excelforum.com/showthread...hreadid=504978



--
grime
------------------------------------------------------------------------
grime's Profile:

http://www.excelforum.com/member.php...o&userid=19227
View this thread: http://www.excelforum.com/showthread...hreadid=504978





All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com