Macro only to run in one sheet?

Richbynature

New Member
Joined
Jun 1, 2011
Messages
2
I'd like my macro only to run in one sheet, please. I have found a few useful examples on this forum of how to stop the macro if it is running on the wrong sheet. However, this makes the macro stop and I am using it to update a live data every 30s.

Is there a way to make the macro continue to run 'in the background' on that one sheet while I do things on other excel sheets. The problem is that when I'm in these sheets they are manipulated by the macro which wrecks the sheet!

If excel can't do this then please let me know (I'm trying to use it dynamically as a real time piece of SW which is not really what it was set up for?).

Thanks,

Rich
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
All calculations are carried on main thread.
 
Upvote 0
I doubt I'm as experienced with excel as you are, so to be clear, what you mean by "main thread" is that the active sheet is always the one that is operated on by the macro?
 
Upvote 0
Have you tried opening a second instance of Excel? I think the latest versions (07 and 10) of Excel can run multithreaded if you have more than one core/processor but I dont know about linking more than one instance together.
 
Upvote 0
Hi Rich, Welcome to the board :)

It's difficult to advise without seeing a sample of your code, but I assume that your macro uses something like:
Code:
Range("A1").Value = "ASDF"
This will always set cell A1 of the CURRENTLY ACTIVE SHEET to the value 'ASDF'.
If you changed it to something like:
Code:
Sub xxx()
Dim WS As Worksheet

Set WS = Sheets("Sheet1")

'... Some code here ...

WS.Range("A1").Value = "ASDF"

'... Some more code ...

End Sub
The macro will always set cell A1 of Sheet1 to the value ASDF.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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