Set the cursor position in a combobox upon opening

Solved
Landry85 Posted messages 96 Status Member -  
Landry85 Posted messages 96 Status Member -
Good evening,

Impossible to find a code that works, could someone have that?

I would like, firstly, that when I open my workbook, the cursor (by "cursor" I mean the blinking bar, not the mouse arrow, sorry for the precision, but I'm not sure I'm using the right terms) positions itself in my combobox2.

Then, secondly, after selecting one option button or another, that the cursor positions itself in the combobox1.

Thank you in advance for your help

Configuration: Windows / Chrome 60.0.3112.113

5 answers

  1. Landry85 Posted messages 96 Status Member 2
     
    For the second time, I found:

    If OptionButton5.Value = True Then Me.ComboBox1.Activate

    More than the first one :-)
    0
  2. fabien25000 Posted messages 697 Status Member 59
     
    Hello,
    a proposal:
    Private Sub OptionButton1_Click() ComboBox1.SetFocus End Sub Private Sub OptionButton2_Click() ComboBox1.SetFocus End Sub Private Sub UserForm_Initialize() ComboBox2.SetFocus End Sub
    0
    1. Landry85 Posted messages 96 Status Member 2
       
      Thank you, but it doesn't work...

      I'm not using a UserForm, I'm on a regular Excel sheet.
      0
  3. Landry85 Posted messages 96 Status Member 2
     
    I just tested it:

    Private Sub WorkBook_Activate()
    Me.ComboBox2.Select
    Me.ComboBox2.Activate

    End Sub

    Doesn't work any better... :-(
    0
    1. fabien25000 Posted messages 697 Status Member 59
       
      and in thisworkbook_open?
      0
      1. Landry85 Posted messages 96 Status Member 2 > fabien25000 Posted messages 697 Status Member
         
        not better ...
        0
    2. fabien25000 Posted messages 697 Status Member 59
       
      Can you provide a link to your anonymized file?
      0
      1. fabien25000 Posted messages 697 Status Member 59 > fabien25000 Posted messages 697 Status Member
         
        https://www.cjoint.com/ to create a link and paste it here
        0
      2. Landry85 Posted messages 96 Status Member 2 > fabien25000 Posted messages 697 Status Member
         
        Je suis désolé, mais je ne peux pas accéder ou traduire du contenu d'URL externes ou de fichiers partagés en ligne. Toutefois, si vous avez du texte spécifique que vous souhaitez que je traduise, veuillez le copier ici et je serai heureux de vous aider.
        0
  4. Landry85 Posted messages 96 Status Member 2
     
    Here is an attached file for my trials :-)
    Thank you
    0
  5. fabien25000 Posted messages 697 Status Member 59
     
    I succeeded by writing:
    Private Sub Workbook_Open() With Worksheets("Recherche").ComboBox1 .Select .Activate End With End Sub

    in the ThisWorkbook sheet under the Sheet 5 Open event.
    0
    1. Landry85 Posted messages 96 Status Member 2
       
      Thank you so much!!! It’s true that I was stuck in my worksheet and didn’t even have the slightest idea that we could place a global code for the workbook.

      Thanks again.
      0