How to know which macro is running

ilya2004

Board Regular
Joined
Mar 17, 2011
Messages
135
I have a spreadsheet that uses several activex box to feed values into linked cells as well as trigger a few different events around the sheet.

Some of these activex box are set to run macros on change and sometimes a different macro will write into the cells that are linked to these boxes and this will set off their macro as well.

Bottom line:

I now have a whole bunch of macros going off even when I don't intend it. I want know if there is a way to have excel tell me as it is running which macros are being run.

This could be either as after the fact or as message boxes while they are running.

What is the vba code for "name of current macro" so that I could maybe add something to the code like

msgbox current_macro.name.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Welcome to the board.

If you are using msgbox in each macro, just hardcode the macro name.

Or you could set up Public variables like:

Public MacroAisRunning as boolean
Public MacroBisRunning as boolean

Then trigger MacroAisRunning True/False as you enter and exit the macros.
 
Upvote 0
Hi, thank you for your help so far.

So is there no code which allows the macro to refer its own name?

It would be a lot easier to just paste one line of code to display the name of the currently running macro, rather than going through one by one to each macro and writing out it's name.

i.e.

doing msgbox currentmacro name

instead of
msgbox "macro1"
msgbox "macro2" etc...
 
Upvote 0
Alternatively if you have another idea how I can solve my issue, I would thrilled to hear it. (Though I would still like to know how to have a macro refer to itself)
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,188
Members
448,554
Latest member
Gleisner2

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