Excel: Nr of times a macro is run from a sheet

Hello everybody I need to count how many times a macro is run from a specific worksheet. For example if I am in sheet A and I run the macro 3 times, it ok to get the value 3, but if I move to sheet B and run it for the first time, I should get the value 1. Then if I move back and run from sheet A, value 4 should appear. Using a static variable like the one from below that holds its value until the worbook is closed doesn't get the job done, because it counts every macro run, no matter from where. Static a As Long a = a + 1

This question generated 7 answers. To proceed to the answers, click here.

This thread is current as of October 11, 2014.

For more resources for Microsoft Excel