1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

run macro if specific cell is changed is not working - it catches any cell changed

Discussion in 'Ask an Excel Question' started by k1s, Mar 20, 2017.

  1. k1s

    k1s Member

    Messages:
    67
    Hi,

    I've got bunch of code that I want to run when a specific cell is changed so the Sub starts:
    Code (vb):

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Application.Intersect(Target, Target.Worksheet.Range("D6")) Is Nothing Then

    'run rest of code...
    Can anybody think why this wouldn't just catch changes in the cell D6?

    For me the rest of the code runs if any cell on the sheet is changed.
  2. PCosta87

    PCosta87 Well-Known Member

    Messages:
    709
    Hi,

    Try:
    Code (vb):
        If Not Intersect(Target, Range("D6")) Is Nothing Then
     
    Hope this helps
  3. k1s

    k1s Member

    Messages:
    67
    That's what I had originally. Same problem. If I change something in say cell C6, the macro runs... I can't work out why
  4. Ramesh

    Ramesh Active Member

    Messages:
    130
    Try execute the following line of code and then your change event should work fine..

    Code (vb):

    Application.EnableEvents=True
     
    PCosta87 and k1s like this.
  5. k1s

    k1s Member

    Messages:
    67
    Thanks, that did it!

Share This Page