help creating a timer


Posted by Kieran Honey on January 24, 2002 2:36 AM

in excel i need a macro to change the colour of this object (easy but it moves so quickly u do not notice the colpour change(theres more code)) I need excel to wait for 0.5 secconds between these to changes (and more) so the change is notable, please coloud anyone please help because I find nothing of any use on the internet. (changes the object white, green , white etc...)

ActiveSheet.Shapes("Object 10").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 9
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid

-------<need a timer here>--------

ActiveSheet.Shapes("Object 10").Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 3
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid

Posted by Juan Pablo G. on January 24, 2002 5:28 AM

Use

Application.Wait

Juan Pablo G.

Posted by j on January 24, 2002 5:30 AM

Posted by Joe Was on January 24, 2002 5:35 AM

Color Flash Code, which may help

Sub FlashBack()
'Make cell range Background color, flash x times, x fast, in x color,
'when Ctrl-a is pressed.

Dim newColor As Integer
Dim myCell As Range
Dim x As Integer
Dim fSpeed

'Make this cell range background flash!
Set myCell = Range("A1:A2")
Application.DisplayStatusBar = True
Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! "

'Make cell background flash to this color!
'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30,
'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11,
'Gray-50% 16, Gray-25% 15, Bright Cyan 8.
newColor = 27

'Make the cell range flash fast: 0.01 to slow: 0.99
fSpeed = 0.2

'Make cell flash, this many times!
Do Until x = 35

'Run loop!
DoEvents
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Interior.ColorIndex = newColor
Loop
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Interior.ColorIndex = xlNone
Loop
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = Application.DisplayStatusBar
End Sub

Sub FlashFont()
'Make cell range font flash, x times, x fast, in x color,
'when Ctrl-z is pressed.
Dim newColor As Integer
Dim myCell As Range
Dim x As Integer
Dim fSpeed

'Make this cell range font flash!
Set myCell = Range("A1:A2")
Application.DisplayStatusBar = True
Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! "

'Make cell font flash to this color!
'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30,
'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11,
'Gray-50% 16, Gray-25% 15, Bright Cyan 8.

newColor = 3

'Make the cell range flash fast: 0.01 to slow: 0.99
fSpeed = 0.3

'Make cell flash, this many times!
Do Until x = 20

'Run loop!
DoEvents
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Font.ColorIndex = newColor
Loop
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Font.ColorIndex = xlAutomatic
Loop
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = Application.DisplayStatusBar
End Sub
Sub reSetFlash()
'Re-set cell range color if edit break on color, Ctrl-r to re-set!
ActiveCell.Select
Selection.Interior.ColorIndex = xlNone
End Sub

25 Black 25
26 Magenta 26
27 Yellow 27
28 Cyan 28
29 Violet 29
30 Dark Red 30
31 Teal 31
32 Blue 32
2 White 2
3 Red 3
41 Light Blue 41
11 Dark Blue 11
16 Gray 50% 16
15 Gray 25% 15

For a set time this will:
Cell range A1:A2 will flash for x background flashes on Ctrl-a,
Ctrl-z the font will flash,
Ctrl-r will reset the range if your edit sticks the color on.
Note: You need to set the hot-keys if any are used. See if this code is any help? JSW

Posted by Joe Was on January 24, 2002 5:35 AM

Color Flash Code, which may help

Sub FlashBack()
'Make cell range Background color, flash x times, x fast, in x color,
'when Ctrl-a is pressed.

Dim newColor As Integer
Dim myCell As Range
Dim x As Integer
Dim fSpeed

'Make this cell range background flash!
Set myCell = Range("A1:A2")
Application.DisplayStatusBar = True
Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! "

'Make cell background flash to this color!
'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30,
'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11,
'Gray-50% 16, Gray-25% 15, Bright Cyan 8.
newColor = 27

'Make the cell range flash fast: 0.01 to slow: 0.99
fSpeed = 0.2

'Make cell flash, this many times!
Do Until x = 35

'Run loop!
DoEvents
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Interior.ColorIndex = newColor
Loop
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Interior.ColorIndex = xlNone
Loop
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = Application.DisplayStatusBar
End Sub

Sub FlashFont()
'Make cell range font flash, x times, x fast, in x color,
'when Ctrl-z is pressed.
Dim newColor As Integer
Dim myCell As Range
Dim x As Integer
Dim fSpeed

'Make this cell range font flash!
Set myCell = Range("A1:A2")
Application.DisplayStatusBar = True
Application.StatusBar = "... Select Cell to Stop and Edit or Wait for Flashing to Stop! "

'Make cell font flash to this color!
'Black 25, Magenta 26, Yellow 27, Cyan 28, Violet 29, Dark Red 30,
'Teal 31, Blue 32, White 2, Red 3, Light Blue 41, Dark Blue 11,
'Gray-50% 16, Gray-25% 15, Bright Cyan 8.

newColor = 3

'Make the cell range flash fast: 0.01 to slow: 0.99
fSpeed = 0.3

'Make cell flash, this many times!
Do Until x = 20

'Run loop!
DoEvents
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Font.ColorIndex = newColor
Loop
Start = Timer
Delay = Start + fSpeed
Do Until Timer > Delay
DoEvents
myCell.Font.ColorIndex = xlAutomatic
Loop
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = Application.DisplayStatusBar
End Sub
Sub reSetFlash()
'Re-set cell range color if edit break on color, Ctrl-r to re-set!
ActiveCell.Select
Selection.Interior.ColorIndex = xlNone
End Sub

25 Black 25
26 Magenta 26
27 Yellow 27
28 Cyan 28
29 Violet 29
30 Dark Red 30
31 Teal 31
32 Blue 32
2 White 2
3 Red 3
41 Light Blue 41
11 Dark Blue 11
16 Gray 50% 16
15 Gray 25% 15

For a set time this will:
Cell range A1:A2 will flash for x background flashes on Ctrl-a,
Ctrl-z the font will flash,
Ctrl-r will reset the range if your edit sticks the color on.
Note: You need to set the hot-keys if any are used. See if this code is any help? JSW

Posted by Joe Was on January 24, 2002 5:45 AM

Wait may suspend processing, Timer will not, see code.

Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 1 seconds", 4)) = vbYes Then
PauseTime = 1 ' Set duration.
Start = Timer ' Set start time.
Do While Timer &LT; Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If

Wait works too but you need to test it if what you want to do such as edit a cell, wait may stop you from doing so or may make the action choppy? The timer just looks at the system clock, the time of which can be used as a trigger, so it has no affect on the processor, like "Wait" does? JSW

Posted by Juan Pablo G. on January 24, 2002 6:06 AM

Joe, i don't know if Timer would work in this case...

... and doesn't this

> Do While Timer &LT; Start + PauseTime
> DoEvents ' Yield to other processes.
> Loop

"disable" your activity as well ? I mean, you DoEvents, but you don't do anything inside the Do, so there's nothing to do... or not ?

Anyway, we're gonna have to 'wait' and see which one works better in this case.

Juan Pablo G.

Posted by Joe Was on January 24, 2002 8:17 AM

Juan you are right, the block is universal...

Yes, You are right Juan, the code block is set up universal and the Do Events will work just like the Wait function. It needs to be changed. JSW



Posted by ted on February 08, 2002 1:36 PM

how to create a username and password(NOT to protect the sheet!)

in excel 97 i need to find out how to create a username and password for a login name to the spreadsheet. so that without this password the data will not be able to be accessed at all. please email me. TEDGINGER@HOTMAIL.COM