code for time of less than 1 second please

Derek

Well-known Member
Joined
Feb 16, 2002
Messages
1,595
Hi all

I am using this code to slow my macro:
Application.Wait Now + TimeValue("00:00:01")
for a wait time of one second. I should like to reduce this to one tenth of a second.
Please can someone tell me how I should word the code for this.
Many thanks
regards
Derek
This message was edited by Derek on 2002-05-28 17:10
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Derek...
This will pause for one-tenth or whatever you choose. Call from your sub as such
SD 0.1
<pre>
Sub SD(LenTime)
Dim Start
Start = Timer + LenTime
Do While Timer < Start
If Timer = 0 Then Start = _
Timer + 1
DoEvents
Loop
End Sub

Sub callTimer()
SD 0.1
End Sub

</pre>
Tom
 
Upvote 0
Put this line of code in the "Declarations" section of a module:

<pre>
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)</pre>

To use this function simply type "Sleep" followed by the number of milliseconds you'd like to pause for. e.g. to pause for 10 milliseconds:

<pre>
Sleep 10</pre>

HTH
 
Upvote 0
Thanks Mark and Tom for you prompt replies. I will try them both.
Have a great day
regards
Derek
 
Upvote 0
Try,

00:00:00.1

If you display the value in a cell?

Format-Cell-Number, select Custom and use:
ss.00

Hope this helps? JSW
 
Upvote 0
Time is basically a number, so, you can still operate with it ! something like this:

?TimeSerial(0,0,1)
12:00:01 a.m.

?TimeSerial(0,0,1)/2
5.78703703703704E-06
 
Upvote 0
Thanks Joe.
I was really trying to pause the macro for a brief moment between events and Tom and Mark's solutions will fit the bill nicely.

Thanks too Juan.
Haven't had my morning caffiene infusion yet so I'm feeling a bit dumb. Would you kindly explain a bit more how one would phrase your method in a macro to create a one-tenth second pause between macro events. If there's lots of ways of doing this I'm keen to learn.

Thanks to all who responded
regards
Derek
 
Upvote 0
Thanks Juan
I couldn't get it to work at first until I added "Now +" to your code, and its fine -
Application.Wait Now + TimeSerial(0, 0, 1) / 10
I've gained lots of knowledge this morning and I shall use it all.
thanks again
regards
Derek
 
Upvote 0
Try,

00:00:00.1

If you display the value in a cell?

Format-Cell-Number, select Custom and use:
ss.00

Hope this helps? JSW

Hi,
I am trying to list times that represents sampling from an A/D board 128 times per second. As an example I have a macro that enters 12:32:44 AM in 128 rows in column A. In my example I have 240 seconds of data, so there are 30K+ rows. I would like to discriminate the time further and sub-label the 128 rows with a divisor. What is the best way to label 12:32:44 AM with 128 divisions and be able to show that in the column instead of 128 "12:32:44 AM."

Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,964
Members
452,371
Latest member
Frana

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