UserForm .SetFocus not working

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
482
Office Version
  1. 365
Platform
  1. Windows
Good morning!

I've been working on this for a while. I have a UserForm named frmOptionComment. I'm trying to set focus to the top-most text box (Option01). Sadly, it's not working at all. No focus is set. Here is my code to open the UserForm:

VBA Code:
Sub OptionComment()
frmOptionComment.Show
End Sub

...and here's the code behind the UserForm...

VBA Code:
Private Sub UserForm_Initialize()

    Application.EnableEvents = False
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

  Me.StartUpPosition = 0
  Me.Left = Application.Left + (0.5 * Application.Width) - (0.5 * Me.Width)
  Me.Top = Application.Top + (0.5 * Application.Height) - (0.5 * Me.Height)
  
OPTIONS_abbreviations.Value = Worksheets("Options").Range("D1")
OPTIONS_descriptions.Value = Worksheets("Options").Range("E1")

Option01.Value = Cells(ActiveCell.Row, "DG")
Option02.Value = Cells(ActiveCell.Row, "DH")
Option03.Value = Cells(ActiveCell.Row, "DI")
Option04.Value = Cells(ActiveCell.Row, "DJ")
Option05.Value = Cells(ActiveCell.Row, "DK")
Option06.Value = Cells(ActiveCell.Row, "DL")
Option07.Value = Cells(ActiveCell.Row, "DM")
Option08.Value = Cells(ActiveCell.Row, "DN")
Option09.Value = Cells(ActiveCell.Row, "DO")
Option10.Value = Cells(ActiveCell.Row, "DP")
Option11.Value = Cells(ActiveCell.Row, "DQ")
Option12.Value = Cells(ActiveCell.Row, "DR")
Option13.Value = Cells(ActiveCell.Row, "DS")
Option14.Value = Cells(ActiveCell.Row, "DT")

Option01.SetFocus

    Application.EnableEvents = True
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True

End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You don't need code. Just make the tabindex of that control 0.
 
Upvote 1

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top