Results 1 to 8 of 8
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ComboBox2 Change (XP)

    I have a workbook that contains a series of ComboBoxes. There is code behind ComboBox2_Change which works just fine. If I were to open another workbook via code the code behind ComboBox2_Change is being run. The line of code to open the workbook does not contain any reference to the code behind ComboBox2_Change.

    I believe it has to do with how Excel handles the "_Change" code. It trys to pass through the code even though no reference is being made to it.

    Can someone confirm my suspisions?

    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ComboBox2 Change (XP)

    When you open the workbook with the combo boxes, whether interactively or using VBA, the ComboBox2_Change event procedure will not be run automatically unless there is a reason for it. If you have code that changes any value in the ListFillRange of the combo box, or the value of the LinkedCell, this will cause ComboBox2_Change to be run.

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ComboBox2 Change (XP)

    Hans,

    Within the code of ComboBox2_Change I do have a ListFillRange being reset of another ComboBox.

    Thanks,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ComboBox2 Change (XP)

    Changing the ListFillRange of another combo box shouldn't cause ComboBox2_Change to run. Changing the value, linked cell or list fill range of ComboBox2 itself (whether directly or indirectly) should trigger ComboBox2_Change.

  5. #5
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ComboBox2 Change (XP)

    Hans,

    Reading further down the code I do have the linked cell being changed.

    Regards,
    John

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ComboBox2 Change (XP)

    If you want to prevent this, you can insert a line

    Application.EnableEvents = False

    before changing the linked cell, and

    Application.EnableEvents = True

    after it. Setting EnableEvents to False suppresses all event processing by Excel.

  7. #7
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ComboBox2 Change (XP)

    Hans,

    Does this also hold true with a ComboBox2_Click event?

    Thanks,
    John

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ComboBox2 Change (XP)

    Setting Application.EnableEvents to False suppresses *all* event processing, whether it is a Click event or a Change event.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •