none
how can highlight the active textbox or combobox in userform vba RRS feed

  • Question

  • dears

    good greeting

    how can highlight the active textbox or combobox in userform vba

    regards...........

    Monday, February 26, 2018 7:37 PM

Answers

  • Hello TAREK SHARAF,

    Do you want to highlight the textbox/combobox while editing them? 

    If so, I would suggest you use Enter Event to change its background color and Exit event to reset it while finish editing.

    Here is the simply code and demonstration.

    Private Sub ComboBox1_Enter()
    Me.ComboBox1.BackColor = vbYellow
    End Sub
    
    Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Me.ComboBox1.BackColor = vbWhite
    End Sub
    
    
    Private Sub TextBox1_Enter()
    Me.TextBox1.BackColor = vbYellow
    End Sub
    
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Me.TextBox1.BackColor = vbWhite
    End Sub

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, February 27, 2018 3:04 AM

All replies

  • Hello TAREK SHARAF,

    Do you want to highlight the textbox/combobox while editing them? 

    If so, I would suggest you use Enter Event to change its background color and Exit event to reset it while finish editing.

    Here is the simply code and demonstration.

    Private Sub ComboBox1_Enter()
    Me.ComboBox1.BackColor = vbYellow
    End Sub
    
    Private Sub ComboBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Me.ComboBox1.BackColor = vbWhite
    End Sub
    
    
    Private Sub TextBox1_Enter()
    Me.TextBox1.BackColor = vbYellow
    End Sub
    
    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Me.TextBox1.BackColor = vbWhite
    End Sub

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Tuesday, February 27, 2018 3:04 AM
  • THANKS

    MY DEAR IT' WORK PERFECT

    REGARDS........

    Tuesday, February 27, 2018 11:44 AM