+ Reply to Thread
Results 1 to 9 of 9

VBA ComboBox_Change firing multiple times

  1. #1
    Registered User
    Join Date
    02-06-2012
    Location
    Maastricht
    MS-Off Ver
    Excel 2007
    Posts
    16

    Question VBA ComboBox_Change firing multiple times

    Hi All,

    I've created an excel document with many defined names.

    I have created some comboboxes users can use to select some values. I use defined names as ListFillRange for the comboboxes.
    I also have a linkedcell for each combobox (in the A-column, which is unprotected but hidden from the users).
    The whole sheet the user sees, is protected (except for the A-column, but that one is hidden).
    The sheet also does not show any headings and no grid. Just for your information...

    The problem that I have is the following:

    I have many lines of VBA code written. All code is working fine, except for the following: (in the Microsoft Excel Objects, in the correct sheet (so not in module, nor in class module))
    Please Login or Register  to view this content.
    The sub mentioned above should reset the combobox entry to the standard country if the user changed it to an unwanted value.
    However, the change fires multiple times, namely 3 times!
    My explanation for this is the following:

    First time it fires: change to "=A11",
    Second time it fires: change to the value of A11, namely "=DefinedNameCountryStandard"
    Third time it fires: change to the value of DefinedNameCountryStandard, namely "The Netherlands".

    I think it's weird that the combobox_change() fires three times, while I expected it to fire only once.

    I tried using Application.EnableEvents = False, but that doesn't work. After some searching on Google I've learned that it doesn't work on user input fields, such as ComboBoxes.
    Then I tried building a variable in my VBA code, but I couldn't get that to work. I tried using a Cell "A20" as a boolean (True/False) and using it like this:
    Please Login or Register  to view this content.
    This code sometimes works fine in my excel document, but sometimes it doesn't and I can't find out why (I'm debugging quite a lot the past few days).
    The sub combobox_change keeps firing multiple times, and same goes for some - if not all - other comboboxes I'm using.
    Because of security-issues I can't post the file, but I've provided you with all the information I think is necessary.

    If anyone else knows a workaround or a solution to my problem, please tell me...

    Thanks,

    Percy Dobbelsteyn
    Last edited by percy1984; 02-06-2012 at 05:32 PM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA ComboBox_Change firing multiple times

    Oops!

    You are bound to receive SERIOUS REPRIMANDS from the Forum's Moderators for not playing by the rules!

    Please read the RULES FIRST, and then quickly, rectify your Post.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    02-06-2012
    Location
    Maastricht
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: VBA ComboBox_Change firing multiple times

    Hi Winon, I've read that post already, but that was something totally different from my problem.
    He was using VBA-code inside a Module, not in Microsoft Excel Objects.
    There the standard way to avoid multiple firing is shown in a reply, but that doesn't work for my problem.
    That's why I decided to create a new Thread for my problem.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA ComboBox_Change firing multiple times

    You need to add code tags to your post before we can tell you the answer.

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]
    Good luck.

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA ComboBox_Change firing multiple times

    @ OEGO,

    Hi OEGO, thanks for backing me up.

    B.T.W. I like the abreviation OEG0!

    Note where the "O" and the Zero should be! LOL

  6. #6
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA ComboBox_Change firing multiple times


    I like mine better.

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA ComboBox_Change firing multiple times

    Since you insist, I have to accept it as such! Zero EGO ?

    Maybe that's why I like you.

  8. #8
    Registered User
    Join Date
    02-06-2012
    Location
    Maastricht
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: VBA ComboBox_Change firing multiple times

    I've added code blocks, and I hope someone can point me in the right direction, thanks for all your input so far, appreciate it ;-)

  9. #9
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: VBA ComboBox_Change firing multiple times

    I think you will find that the issue is your links to the sheet with ListFillRange. If you populate the combo boxes in code (you can just assign the value of the ranges to the List property), you should not have the issue.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1