(Solved) – Run macro on change within target range | Change (ByVal Target As Range)

  • by
(solved)-–-run-macro-on-change-within-target-range-|-change-(byval-target-as-range)

I’m quite new to coding using vba, but I know how to work with the Worksheet_Change(ByVal Target As Range) function.
I wanted to run a macro if either on of cells [A1] or [A2] are changed.
So the target range is set to [A1, A2]

I then – if [A1] is changed – want to clear [A2], or the other way around ([A2] is changed: clear [A1]).
Now the problem:
If [A1] value is changed. the macro clears [A2]. That’s seen as a change in [A2], so it clears [A1], which is a change, etc…

I’m sure it’s something simple, but I can’t see how I can have cell [A1] be changed without triggering the change macro if [A2] is being cleared.

Anyone who has experience in this?

Leave a Reply

Your email address will not be published. Required fields are marked *