ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Whoa horsie Slow down (https://www.excelbanter.com/excel-programming/288446-whoa-horsie-slow-down.html)

pete

Whoa horsie Slow down
 
Can anyone tell me how to slow down macro or choose how
fast a macro runs. If you have a macro with screen
updating turned on I want it to slow down enough to view
the date being entered.

Any ideas on this.
Pete

Trevor Shuttleworth

Whoa horsie Slow down
 
Pete

not something people are usually looking for. Try something like this:

Sub SlowDownTest()
Range("A1") = "a"
SlowDownLoop
Range("B1") = "b"
SlowDownLoop
Range("C1") = "c"
SlowDownLoop
Range("D1") = "d"
SlowDownLoop
Range("E1") = "e"
SlowDownLoop
End Sub

Private Sub SlowDownLoop()
Const LoopCount = 10000000
Dim i As Long
For i = 1 To LoopCount
Next i
End Sub

Vary the value of LoopCount to match your needs. You might need to add a
zero or double the value, etc.

Regards

Trevor


"Pete" wrote in message
...
Can anyone tell me how to slow down macro or choose how
fast a macro runs. If you have a macro with screen
updating turned on I want it to slow down enough to view
the date being entered.

Any ideas on this.
Pete




Jim Cone

Whoa horsie Slow down
 
Pete,
Another way from mskb 162150 ...

Use an API call to suspend execution for a fixed amount of time.
The Kernel32 contains a function that pauses a program's execution for a
specified amount of time, specified in milliseconds. To use the function, it
must first be declared in the General Declarations section of the module in
which it will be used:
'--------------------------------------------------
Declare Sub Sleep Lib "kernel32" Alias "Sleep" _
(ByVal dwMilliseconds As Long)

'Use the following syntax to call the Sleep function:
Sub Sleep()
Sleep 1000 'Implements a 1 second delay
End Sub
'--------------------------------------------------
Regards,
Jim Cone
San Francisco, CA

"Pete" wrote in message
...
Can anyone tell me how to slow down macro or choose how
fast a macro runs. If you have a macro with screen
updating turned on I want it to slow down enough to view
the date being entered.
Any ideas on this.
Pete




No Name

Whoa horsie Slow down
 
Trevor

I can't get the second option you suggested to work
properly without running in a massive continous loop. here
is my code below, can you get to work? What i want to see
is where the words "No Match are insert in my first range.
But I don't want it to fly by soo fast that the user can't
reconize it.

Application.ScreenUpdating = True

Set MyFirstRange = Range("z3:z220")
Set MySecondRange = Range("b3:b220")
fnd = 0

For Each c In MyFirstRange
For Each n In MySecondRange
If c.Value = n.Value Then
c.Offset(0, 4).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next
If fnd = 0 Then c.Offset(0, 4).Value = "No Match"
fnd = 0
Next

Thanks
Pete

-----Original Message-----
Pete

not something people are usually looking for. Try

something like this:

Sub SlowDownTest()
Range("A1") = "a"
SlowDownLoop
Range("B1") = "b"
SlowDownLoop
Range("C1") = "c"
SlowDownLoop
Range("D1") = "d"
SlowDownLoop
Range("E1") = "e"
SlowDownLoop
End Sub

Private Sub SlowDownLoop()
Const LoopCount = 10000000
Dim i As Long
For i = 1 To LoopCount
Next i
End Sub

Vary the value of LoopCount to match your needs. You

might need to add a
zero or double the value, etc.

Regards

Trevor


"Pete" wrote in

message
...
Can anyone tell me how to slow down macro or choose how
fast a macro runs. If you have a macro with screen
updating turned on I want it to slow down enough to view
the date being entered.

Any ideas on this.
Pete



.


Trevor Shuttleworth

Whoa horsie Slow down
 
Not sure I understand "second option". The first piece of code simply
demonstrates the SlowDownLoop subroutine. In your example, I think you need
to put the call to the subroutine as shown.

For Each c In MyFirstRange
For Each n In MySecondRange
If c.Value = n.Value Then
c.Offset(0, 4).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next
If fnd = 0 Then
c.Offset(0, 4).Value = "No Match"
SlowDownLoop
End If
fnd = 0

Next

Regards

Trevor


wrote in message
...
Trevor

I can't get the second option you suggested to work
properly without running in a massive continous loop. here
is my code below, can you get to work? What i want to see
is where the words "No Match are insert in my first range.
But I don't want it to fly by soo fast that the user can't
reconize it.

Application.ScreenUpdating = True

Set MyFirstRange = Range("z3:z220")
Set MySecondRange = Range("b3:b220")
fnd = 0

For Each c In MyFirstRange
For Each n In MySecondRange
If c.Value = n.Value Then
c.Offset(0, 4).Value = n.Offset(0, 4).Value
fnd = 1
End If
Next
If fnd = 0 Then c.Offset(0, 4).Value = "No Match"
fnd = 0
Next

Thanks
Pete

-----Original Message-----
Pete

not something people are usually looking for. Try

something like this:

Sub SlowDownTest()
Range("A1") = "a"
SlowDownLoop
Range("B1") = "b"
SlowDownLoop
Range("C1") = "c"
SlowDownLoop
Range("D1") = "d"
SlowDownLoop
Range("E1") = "e"
SlowDownLoop
End Sub

Private Sub SlowDownLoop()
Const LoopCount = 10000000
Dim i As Long
For i = 1 To LoopCount
Next i
End Sub

Vary the value of LoopCount to match your needs. You

might need to add a
zero or double the value, etc.

Regards

Trevor


"Pete" wrote in

message
...
Can anyone tell me how to slow down macro or choose how
fast a macro runs. If you have a macro with screen
updating turned on I want it to slow down enough to view
the date being entered.

Any ideas on this.
Pete



.




Ryan Poth[_3_]

Whoa horsie Slow down
 
I'm surprised nobody has suggested this yet, but have a
look at the Wait method in your Excel Help.

-----Original Message-----
Can anyone tell me how to slow down macro or choose how
fast a macro runs. If you have a macro with screen
updating turned on I want it to slow down enough to view
the date being entered.

Any ideas on this.
Pete
.



All times are GMT +1. The time now is 02:26 AM.

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