Set Focus on Combobox

  • I have an application in excel in which a “combobox1” has been created on the main sheet of excel. Somewhere during the code execution the program requires input from the “combobox1”. What is the code required to highlight the “combobox1” allow the user to select from the box and then return control back to the regular code?

  • Re: Set Focus on Combobox


    Quote

    allow the user to select from the box and then return control back to the regular code


    Hi, small remark:


    I think you have to write 2 procedures instead of 1 program that should interact. The first program should do the things without the combobox and the second should trigger if the user selects an item of the box. That way the box doesn't have to be activated.


    (By the way I don't know how you activate the box on a sheet. selecting yes, but activating no)

  • Re: Set Focus on Combobox


    I don't think the setfocus is supported for a combobox on a sheet. For a box on a form => ok, but not on a sheet.

  • Re: Set Focus on Combobox


    Quote from Phil Policelli;253917

    I have an application in excel in which a “combobox1” has been created on the main sheet of excel. Somewhere during the code execution the program requires input from the “combobox1”. What is the code required to highlight the “combobox1” allow the user to select from the box and then return control back to the regular code?


    To setfocus on a ComboBox in a sheet you need activesheet.combobox1.activate or sheets("your sheet name").combobox.activate


    to continue the rest of the code there are several ways, it would be good to have a sample of the code or more info. It seams that you have a variant that will need the ComboBox value to continue. If that is so you should have it either using something like my.variant = combobox1.value or by splinting the code.

  • Where should that code go? activesheet.combobox1.activate

  • This thread is 10 years old. I suggest you start your own thread if you have a problem to solve.

    Rory
    Theory is when you know something, but it doesn’t work. Practice is when something works, but you don’t know why. Programmers combine theory and practice: nothing works and they don’t know why

Participate now!

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