+ Reply to Thread
Results 1 to 7 of 7

ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

  1. #1
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    Hello,

    Thank you in advance. Anonymized copy of project attached.

    I have two (2) combo-boxes in the sheet labled "Analysis". The first combo-box "cmBox_SelectSection" sets the .ListFillRange property of the second combo-box, called cmbox_SelectBidItem via the following code in during the Change() event of cmBox_SelectSection so that cmbox_SelectBidItem is only populated with those items that match the Section selected in cmBox_SelectSection:

    Please Login or Register  to view this content.
    This all works fine if and until the user attempts to edit the value of cmbox_SelectBidItem. Excel immediately crashes if cmbox_SelectBidItem gets focus and the user edits the text string of the value property.

    I have set the Style property of both combo-boxes to 2 - fmStyleDropDownList and added the following to the KeyPress() event for both:

    Please Login or Register  to view this content.
    The above code solved the crash except for when backspace is pressed when the value of cmbox_SelectBidItem is highlighted.

    The .Value property of cmBox_SelectBidItem is used in the Click() event of cmdbtn_RetriveBidItems and to set the value of cell $C$8 in the Analysis tab. It is used nowhere else in the project.

    How to I solve this? Is there a way to entirely lockout keyboard commands from affecting a combo-box? My guess is this has something to do with how I'm populating the .ListFillRange property of cmBox_SelectBidItem but I'm not sure? Is there a better way I could assign the dynamic range to populate the .ListFillRange property? Open to any suggestions.

    Appreciate your time and input.

  2. #2
    Registered User
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    88

    Re: ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    ActiveX combobox objects in Excel do not behave well when their ListFillRange refers to a named range based on a formula (defined name) because
    the combobox_Change() event fires whenever any cell in the workbook is changed or the worksheet is recalculated. Therefore, for the ListFillRange of the cmBox_SelectSection control, you must enter the fixed address of the cell range or use code to add the list values ​​to the control, e.g. using the AddItem method.

    Edit: I made a small example:
    Add to ThisWorkbook module:
    Please Login or Register  to view this content.
    In the sheet "Sections" module:
    Please Login or Register  to view this content.
    Save and reopen the file.
    Last edited by Tajan; 12-21-2023 at 06:55 PM.

  3. #3
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Re: ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    I see. That would explain why I've been seeing Debug.print calls firing twice.

    I think this pretty much tells me to find another way to accomplish what I want. I will mark this thread as solved and redesign around standard VBA Form Controls or good old dependent drop drowns.

    Appreciate your time.

  4. #4
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Re: ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    I just saw your edit. I'm trying to avoid the Worksheet_Change event as I've found it to be overly volatile and can really slow down calculation time. I appreciate the approach, through.

  5. #5
    Registered User
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    88

    Re: ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    It won't slow you down. The procedure will only work if you change the value in column B or C of the "Sections" sheet. Try it.

  6. #6
    Forum Contributor
    Join Date
    03-30-2016
    Location
    Gillette, WY
    MS-Off Ver
    Office 365
    Posts
    230

    Re: ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    The issue isn't with cmBox_SelectSection, that is populated from the a pretty much static range called lstrng_Sections.

    Populating and using the dependent cmBox_SelectBidItem is the problem.

    Am I missing something, how does your code suggestion populate cmBox_SelectBidItem with the bid items from the Bid Items sheet that match the Section selected in cmBox_SelectSection?

  7. #7
    Registered User
    Join Date
    10-16-2023
    Location
    Poland
    MS-Off Ver
    Excel 2019 32bit WIN10
    Posts
    88

    Re: ActiveX ComboBox with Dependent Dynamic List Range Crash on Text Value Edit

    No. ListFillRange cmBox_SelectSection is populate from a name "lstrng_Sections" referring to the formula: "=OFFSET(Sections!$B$2,,,COUNTA(Sections!$B:$B)-1,1)" . This is the main problem.
    Last edited by Tajan; 12-21-2023 at 07:51 PM.

+ 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] Dependent DropDown lists in VBA /=INDIRECT() on ActiveX ComboBox/
    By bongo_bg in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2018, 02:03 AM
  2. [SOLVED] Value Dependent Dynamic Range ComboBox in Userform
    By Dferrier in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2016, 04:27 AM
  3. ActiveX Controls: How to make a dependent list when Range is in a different sheet
    By Fahsai in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2016, 02:29 AM
  4. Dependent Data Validation List with Dynamic Range
    By sakmsb in forum Excel General
    Replies: 1
    Last Post: 06-09-2015, 12:42 PM
  5. Populating an ActiveX combobox from a dynamic list
    By Mel_GC in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-23-2014, 11:10 AM
  6. activex combobox and dynamic named range
    By lcsw in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2013, 05:30 PM
  7. Dependent Combobox on Form not updating from dynamic range
    By ron2k_1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-08-2011, 12:59 PM

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