ActiveX combobox objects in Excel do not behave well when their ListFillRange refers to a formula-based Named Range (Defined Name).
I think I have encountered other errors and possibly even Excel crashes thanks to this, but right now all that happens is the combobox_change() event is triggered anytime ANY cell in the workbook is changed.
I am not sure if this is really a bug, or if there is a fix, or a workaround. If it is a bug, how do I report it to the Excel people?
And finally, the real meat of my question is "How do I work around this issue best?" I would like to have some formula-based named ranges, but it seems like this won't be possible.
To reproduce this bug, do the following:
- Create a new workbook. On Sheet3, create a small table 3 columns across, and several rows high.
- Create a named range with this formula (or an equivalent): =OFFSET(Sheet3!$A$2:$C$36,0,0,COUNTA(Sheet3!$A:$A),COUNTA(Sheet3!$4:$4)) To do this use Input>Name>Define. Name the range something like "demoRange"
- Go to Sheet1 and create a combobox, (it must be on a separate sheet). (Use the Control Toolbox menu, not the Forms menu).
- Click on the Design Mode button (the blue triangle with pencil), then right click on the combo box and go to Properties.
- In the properties window for the combobox, change the ListFillRange property so that it points at the named range you created in step 2 ("demoRange").
- You may want to change the ColumnCount property to 3, and the ColumnWidths property to "50,50,50"
- Set the linkedCell property to cell "A1" by typing A1 in the linkedCell property.
- Close the properties window, and double click on the combobox to define its change() event.
- Put a Debug.Assert(false) or Msgbox("demo") line in the subroutine for the new combobox's change event.
- Exit design mode
- important - Now select an item in the combobox. The event should trigger normally the first time. (The bug will not show if you don't do this step--something must be selected in the combobox)
- Edit cells anywhere in the workbook [Edit] or any other open workbook [/edit], on any sheet and any location. Each time you edit any cell, (at least for me), the onchange event for the combo box is run.
Again, is this normal, and what is the best alternative for what I am doing? This combo box gets linked to various cells, and is supposed to be a replacement for the tiny font in the data validation dropdowns excel provides by default.