Clear an activex combobox after a VBA macro is ran.

  • Hi!
    How are you?


    I really need your help to resolve 1 simple question that will enable me to finish my work.


    Question: How can I clear an activex combobox selection with my macros through a VBA sub if i'm not using a form? the activex combobox is in a sheet, without a form.
    Basically I have a macro that reads an activex combobox and does something, when it finishes it's job I need the A.C. to go from [ATTACH=CONFIG]73495[/ATTACH] to [ATTACH=CONFIG]73496[/ATTACH], that's it




    Background info:
    I created 3 buttons to edit, add or delete entries from a list in another sheet acting as a database, the entry to be modified is selected by the user from an activex combobox dropdown list.
    The problem is that after the buttons' macro finishes their job, I need the entry selected to not be selected anymore in the activex combobox for 'cleanliness purposes' and to avoid 'layer 8 mistakes', currently the user selection remains there.

  • Re: Urgent: howto - Clear an activex combobox after a VBA macro is ran.


    try adding this to your code at the end. Change the combo box name to reflect your combo box name in your code.


    Code
    combobox1.value = ""
  • Re: Clear an activex combobox after a VBA macro is ran.


    If your macro is placed on the Sheet Module of the sheet where your ComboBox1 (name of the ComboBox1) is placed, you will need the below line to clear the selection of the ComboBox1...


    Code
    ComboBox1.Value = ""


    But if your macro is placed on a Standard Module like Module1 etc., you need below line to clear the selection...

    Code
    'Declare a sheet variable to hold the target sheet
    Dim ws As Worksheet
    'Set the worksheet as required
    Set ws = ActiveSheet
    ws.OLEObjects("ComboBox1").Object.Value = ""

    Regards.
    sktneer

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!