MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Working with Userform Controls


January 14, 2002 - by Bill Jelen

GH asks:

I'm facing a problem today, I have a user form with 5 different text boxes, 3 of those text boxes are mandatory. If I don't put nothing in one of those text boxes and I click the command button to perform the verification, I have a message box that appears and tells me that the text box "XXXX" is mandatory. When I click OK on this message box I would like my VBA project to select/activate the text box where data is mandatory.

Use the .SetFocus command:

Me.TextBox3.SetFocus

Bill Jelen is the author / co-author of
Power Excel With MrExcel - 2017 Edition

This is the print book edition of "Power Excel with MrExcel - 2017 Edition" - by Bill Jelen. Master Pivot Tables, Subtotals, Visualizations, VLOOKUP, Power BI and Data Analysis.