+ Reply to Thread
Results 1 to 14 of 14

ActiveX combobox click triggers unwanted another comboxbox click event

  1. #1
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    ActiveX combobox click triggers unwanted another comboxbox click event

    I have two (or 3) comboboxes with one controlling the listfillrange of another. It works fine except when I add a line to capture the value of the combobox on a sheet. After the recording the value line, it jumps to the first combobox click event that I don't want:

    Please Login or Register  to view this content.
    When I click combobox2, it triggers the combobox1 event and wipes out the selection in the combobox2 after the line: sheet2.range("b2")=me.cbo2.value. How can I stop this from happening? I tried enableEvents, combobox.list,etc. to no avail. Many Thanks in advance!

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    I think there is a typo in your description or your code...
    One says Sheet2.Range("b2")=me.cbo2.value
    The other says Sheet2.Range("B1") = Me.cbo2.Value
    Not that either one is the problem.
    Not seeing anything that would cause ComboBox1 to trigger when clicking/changing ComboBox2, unless 1 is dependent on 2.
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    sheet2.Range("A1") = Me.cbo1.value

    If cbo1 is populated by its .ListFillRange property and that list-range includes cell Sheet2.Range("A1") , then writing to a cell in its list-range will trigger cbo1 to re-populate and in turn trigger it's _Click event.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    AlhpaFrog: Yes cbo1 listfillrange is set in its property to a namerange((it's on sheet1). It doesn't include cell sheet2.range("A1"). Somehow it still triggers cbo1 click...I tried enableEvents but it didn't work

    Tom: cbo2 is dependent on cbo1, when cbo1 equals certain value cbo2 populates with corresponding values.
    Last edited by aprildu; 12-11-2015 at 12:36 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    Quote Originally Posted by aprildu View Post
    AlhpaFrog: Yes cbo1 listfillrange is set in its property to a namerange but it doesn't include cell sheet2.range("A1") (it's on sheet3). Somehow it still triggers cbo1 click...I tried enableEvents but it didn't work
    Is the named range for the List on Sheet2 as well? If yes, then as a test, write the cbo values to a different sheet.

    You are correct in that EnableEvents has no effect on controls.

  6. #6
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    I just found out that I made an error in my original code. The name range for cbo1 is on sheet1 and cbo2 added items are also on sheet1. But I typed in sheet5 instead (in my original file that didn't work not the sample code above). Still it's strange why it would trigger the cbo1 click event. Thanks AlphaFrog you are always a lifesaver!
    Last edited by aprildu; 12-11-2015 at 01:38 PM.

  7. #7
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    It's happening again. I tried the code in a clean workbook and it doesn't trigger the cbo1. But it just happens in my original workbook even when I copied the code into it. The combo values are in a totally blank sheet. What could be the reasons?

  8. #8
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    Are you using any RANDOM (RAND) formulas anywhere? Or, do you have a Worksheet_Change event code that you are using?

  9. #9
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    Quote Originally Posted by gmr4evr1 View Post
    Are you using any RANDOM (RAND) formulas anywhere? Or, do you have a Worksheet_Change event code that you are using?
    No there is no rand formula anywhere. I think it's because the cbo1 listfillrange is set in the same sheet as the items that are added to cbo2. Hopefully this time won't happen again Otherwise I want to pull my hair out

  10. #10
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    Been there, now I'm bald!

  11. #11
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    OK I am going bald too. I changed the cbo1 listfillrange to a dynamic range (offset....) and it is happening again. Is this the reason and why?

  12. #12
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    I'm am not familiar enough with coding a ComboBox in the manner that you have, so any info/suggestions I provide might be level 1 rookie stuff that makes no sense. Such as....List 1 and 2 are being set to = New Collection. Could this be causing the problem as they are both set to the same thing so one triggers the other?

  13. #13
    Forum Contributor aprildu's Avatar
    Join Date
    04-13-2014
    Location
    Barrie,On, Canada
    MS-Off Ver
    Excel 2016
    Posts
    175

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    I think it's the dynamic range for cbo1 1 listfillrange that's triggering cbo1 click event. I tried it in a clean book (to eliminate other possible errors). It worked fine with a static name range until I changed to dynamic range. Don't know why but excel does 'strange things' once in awhile anyways. I resorted to populate cbo1 the same way (collection) as cbo2 and cbo3. It's working now finger crossed. And I am not touching/changing this block anymore lol.
    Last edited by aprildu; 12-12-2015 at 09:24 AM.

  14. #14
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: ActiveX combobox click triggers unwanted another comboxbox click event

    lol, good luck. This might be a good reason for me to stick to naming the range in the Row Source of the properties window. keeps me from having to figure out the code I need (and the issues that go along with it).

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Checking ActiveX checkbox triggers another event.
    By ARowbot in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2015, 10:35 AM
  2. Click v double click event code
    By Greg J in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2014, 04:08 AM
  3. [SOLVED] I need a simple code for a click event using a UserForm ComboBox
    By Pyro Form in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2012, 07:58 AM
  4. Prevent ListBox Click Event Until Mouse Click
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2011, 12:23 PM
  5. [SOLVED] Combobox - can't get click event to run for first item in the list
    By Dale in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-08-2006, 10:00 PM
  6. userform label double-click goes to click event
    By John Paul Fullerton in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-19-2006, 01:00 PM
  7. Re: Combobox Click event triggered when copying worksheet
    By Intellihome in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-30-2005, 01:05 PM

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