Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call Sub only if a USER changes the worksheet, not VBA code

Tags:

excel

vba

I have a Worksheet_Change event where if a cell in column F changes, a message pops up asking if the user wants to change the cell text.

Now, I have VBA code that inserts new rows and, therefore, makes changes in column F, but I don't want the message to pop up or this code to be called at all.

Is there a way to distinguish between a user and Excel itself (VBA) making a change on the worksheet?

like image 777
anonymous Avatar asked Dec 23 '22 20:12

anonymous


1 Answers

Just insert the line

Application.EnableEvents = False

before executing your code and then (at the end) set

Application.EnableEvents = True

again to make sure that Excel reacts to Events on the worksheet again.

For more information read this: https://msdn.microsoft.com/en-us/library/office/ff821508.aspx

like image 123
Ralph Avatar answered Jan 30 '23 13:01

Ralph