Search code examples
excelvbauser-interfacecomboboxactivex

Excel ActiveX ComboBox Displays Previous Value Issue


Issue with Embedded ActiveX ComboBox form on a spreadsheet where:

  • Upon changing the value in the ComboBox, the value changes properly
  • However, when a cell/shape is selected on the sheet, the ComboBox value reverts back to the previous value for a split second before going back to the new value

  • Problem because: If a button for a macro is pressed after changing the ComboBox value, the old ComboBox value is displayed while the macro is running, rather than the new value

Question: Is there a way to force this event (reverting to old value before going displaying new value) programmatically?

I've tried using the following in the Change event for the ComboBox, as well as within the macro that is called by another shape on the sheet:

  • Calculating the worksheet
  • Selecting/Activating a cell
  • ScreenUpdating = false, ScreenUpdating = true

Did a bit more searching and have found this question Excel ActiveX Combobox shows previous selection when losing focus with the same issue


Solution

  • Added a LostFocus event to the ComboBox that had a line that selected a cell. This removed the "flicker" to the previous value when another cell on the sheet was selected, and also caused the ComboBox value to "flicker" back to the new value after "flickering" to the old value when a command button was clicked after changing the ComboBox's value...

    Therefore this solved my issue (mostly -- was unable to prevent the "flicker" from happening upon running another macro via command button, but at least the value does not remain stuck at the old value while the other macro runs)

    Idea came from this thread: What event is triggered when user selects value from drop down ComboBox (ActiveX)?