0
votes

Is there any way I can capture if the change in workbook was done by user interface or VBA macro?

I have VSTO addin doing some stuff when user changes some cells in many files population. Some of the files have VBA macro in them and these macros can modify the same cells. I want to ignore this kind of action when the source of action is in VBA code.

My idea so far: 1) Events - did'n not find the right one 2) System Stack - have no idea how and for what I should looking for 3) Dynamic VBA code modification - adding flags - not elegant and not safe.

Thanks for any help

1
You cannot know if a cell was changed by a user or VBA code. If you want to ignore Worksheet_Change raised in response to VBA code, you will have to set EnableEvents = False before letting the macro run, but that alone can break the macro.GSerg

1 Answers

0
votes

There is no way to detect who performs changes on the worksheet. If a Worksheet is hidden (see the Visible property) and the Change event is fired then a VBA or VSTO code works.