Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Excel macros in the bakground 1

Status
Not open for further replies.

unknownmuncher

Technical User
Oct 1, 2004
13
US
Is there any way to run macros (specifically Excel macros) in the background? For example, I've got a macro that counts elapsed time and spits it out into a cell, but I want that time to continually update. I also want to be able to change cell values on the sheet while this timer is running.

Is it even possible? And if so, how do I accomplish this?

Eli Morris-Heft
"If at first you don't succeed, skydiving is not for you.
 
ukm,

Take a look at the Timer Function in your VB Editor. The EXAMPLE shows how you can use DoEvents with a Timer to run while other things, like user events, can take place.

Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
That's very close to what I want to do, but the way that the DoEvents and Timer combo seems to be laid out means that whatever process I'm running (e.g. counting up since a certain event) has to pause for DoEvents to let me change cell values.

This wouldn't be a problem if all that this workbook was supposed to do was count elapsed time. The problem is, it's got other data that I need to be able to change while the elapsed-time counter is running. In other words, I need my workbook to present "live" data - data that can be changed to represent current cirucumstances.

Am I just being too greedy in insisting that I should be able to change data while the computer is updating its elapsed time?

p.s. Sorry about the thread spelling. I usually know better than that ^^;;

Eli Morris-Heft
"If at first you don't succeed, skydiving is not for you.
 
You ought to be able to do anything.

Skip,

[glasses] [red]Be advised:[/red] It's been reported that a wee psychic is roaming the countryside.
Small Medium @ Large! [tongue]
 
Thanks for your all your help, Skip.

Just one more thing: I've got it set up so the macro gives me 8 seconds of DoEvents time before it restarts (because I've got this DoEvents portion of it and it's supposed to be counting elapsed time, the entire macro is encompassed by a Do...Loop . If I need to break it, I can set it up again, so it's not really a big thing.)

I've got several cells over several sheets set up so they have pull-down menus. If I'm on a different worksheet than the macro is working on, then during my 8 seconds I go to change something on the unaffected worksheet, the pull-down menu has changed into the the pull-down menu of another cell on the worksheet the macro is working on.

So to clarify, I've got a pull-down menu for cell C3 on Sheet1 (for genericism). I'm looking at Sheet2 and I wait for my 8 seconds. I go to pull down the menu on Sheet2!C3 and the menu I get is what should be the menu for Sheet1!C3.

Morever, if I'm on Sheet1 and wait for my 8 seconds, then pull down Sheet1!C3, it is difficult to do so - i.e. it will select D3, or refuse to pull down, etc.

Would seeing my code help fix this? I doubt it, but one never knows.

Eli Morris-Heft
"If at first you don't succeed, skydiving is not for you.
 
Never mind that last one - I figured out a way to frame my DoEvents. Because I only need to macro to spit out elapsed time on one sheet (I was having troubles with the sheet called "Radios"), I can add

Code:
    Do While Application.ActiveSheet.Name = "Radios"
        DoEvents
    Loop

right after my For-Next loop and before the Loop that goes with the Do at the beginning of my macros. Huzzah for solving things.

Thanks for the DoEvents tip, though. It helped immensely.

Eli Morris-Heft
"If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top