Computing.Net > Forums > Office Software > Controlling speed macro runs at

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Controlling speed macro runs at

Reply to Message Icon

Name: Bryco
Date: July 2, 2007 at 09:26:13 Pacific
OS: Win XP Pro sp2
CPU/Ram: 3Ghz/1Gb
Product: Dell Dim 8400
Comment:

Using Excel 97

I am entering a number into a field that produces a formula result in another cell.

I am entering 80 separate numbers into the original cell one at a time.

I can record a macro that enters the 80 numbers for me but the macro runs so fast that I cannot see/record the results of it's input.

I tried inserting Application.Wait (Time) and it suggests 0-500 for a variable. Entering 500 or less I cannot see the results. I cannot even see any wait at all.

If I enter 50000 then it will wait until I hit the escape key but then the macro runs to it's completion.

How can I control the speed on which it runs? .5 to .75 seconds or even 1 second on each number would suffice.

Sub Keno1()
'
' Keno1 Macro
' Macro recorded 7/2/2007 by Bryco
'
' Keyboard Shortcut: Ctrl+k
'
Range("AB2").Select
ActiveCell.FormulaR1C1 = "1"
Application.Wait (50000)
Range("AB2").Select
ActiveCell.FormulaR1C1 = "2"
Range("AB2").Select
ActiveCell.FormulaR1C1 = "3"
Range("AB2").Select
ActiveCell.FormulaR1C1 = "4"

Using the above it does "wait" after the first number is entered.

If I insert the Application.Wait (50000) after each number it apparently does not see it. Obviously I have no idea how to make it work.

Any ideas?

Additionally, when I step through the macro I have to hit F8 to go through each step. Is there a way to Step through the macro while viewing the Excel worksheet?

One more; How can I quit Stepping through when in VBA editor? I forgot as it has been a while.

VBA Help is missing from my installation. It cannot find VEENUI3.HLP.

With much thanks,
Bryan



Sponsored Link
Ads by Google

Response Number 1
Name: DerbyDad03
Date: July 2, 2007 at 09:58:50 Pacific
Reply:

A combination of the text from the Help files for Wait and a little customization...

Sub KenoNew()
For NewNum = 1 To 4
[ab2] = NewNum
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
Next
End Sub

This will work for a 1 second delay. I don't think it likes anything less than 1 second.

- Is there a way to Step through the macro while viewing the Excel worksheet?

Resize the VBA editor window and put it in front of the spreadsheet. Move it around as required.

- How can I quit Stepping through when in VBA editor?

Options:
1 - Click the blue square Stop button to Stop.
2 - Click the green triangle Run button to run through the end of the code.
3 - Drag the yellow arrow to the End Sub line and hit F8. (I tell you this so you'll know that once you're in single step mode, you can drag the arrow anywhere you want and single step from that point. There are some caveats, e.g. you can't start in the middle of a loop, but you'll discover them as you run across them.)

You can also put the cursor on any line you want and hit Ctrl-F8 to run the code to that point and then single step (F8) from there. That's a quick way to run through what you know works and then single step through your trouble spots.

Get your Help files fixed. It's real hard to learn/use VBA without them. The examples alone are worth the price.



0

Response Number 2
Name: Bryco
Date: July 2, 2007 at 11:47:07 Pacific
Reply:

DerbyDad03

Thank you very much. It worked great.
This will keep me from getting carpo tunnel syndrome.

Thanks again,
Bryan


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Office Software Forum Home


Sponsored links

Ads by Google


Results for: Controlling speed macro runs at

Disable Flickering screen when running macro www.computing.net/answers/office/disable-flickering-screen-when-running-macro/9522.html

Running excel VBA Code from a pre 2003 Macro www.computing.net/answers/office/running-excel-vba-code-from-a-pre-2003-macro/9591.html

Run Excel Macro as Automated Task on Server www.computing.net/answers/office/run-excel-macro-as-automated-task-on-server/9661.html