Link to home
Start Free TrialLog in
Avatar of Geekamo
GeekamoFlag for United States of America

asked on

VBA - Clear contens of cell, if other cells change

Hello Experts,

I am using some VBA code, but it doesn't appear to be working/running? (I have no idea how to verify its even executing)

Here is the code...

Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Address = "pmDimensions" Then
            Range("pmSeal").Value = ""
        End If
    End With
End Sub

Open in new window


pmDimensions consists of 3 cells.   Basically, if any value changes, then I want to clear the contents of pmSeal.

Any ideas what is wrong with the code above?
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

You have to turn off events for the code to behave well:

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    With Target
        If .Address = "pmDimensions" Then
            Range("pmSeal").Value = ""
        End If
    End With
    Application.EnableEvents = True
End Sub

Kevin
ASKER CERTIFIED SOLUTION
Avatar of zorvek (Kevin Jones)
zorvek (Kevin Jones)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Geekamo

ASKER

This worked great - thanks Kevin!