Link to home
Create AccountLog in
Avatar of sidwelle
sidwelleFlag for United States of America

asked on

VBA Userform looses focus to worksheet in Excel

VBA UserForm looses focus.


I have developed a few Macros/applications in VBA that make use of a UserForm.

Problem:  During testing I find that after I start application, the form looses focus and/or minimizes or a worksheet from the workbook takes focus.  Form is no longer in view !

Either way, the form is still alive and normalized, I just have to go hunting for it.

The form does not show an Icon in the taskbar, so I usually find it by clicking on one of the worksheets that are open from the taskbar and it shows up w/focus in front of one of the Worksheet(s).


Can anyone shed light on why it is doing this ?

Thanks




Avatar of Rob Henson
Rob Henson
Flag of United Kingdom of Great Britain and Northern Ireland image

Check the properties of the User Form. ShowModal property needs to be set to True for it to keep focus until it is closed.


User generated image


ShowModal property (Visual Basic for Applications) | Microsoft Learn

Avatar of sidwelle

ASKER

That appears to have worked.  I had that set to Non-Modal so that I could get behind the form and look at the worksheet if I needed to after the form was loaded.  

I guess the users will have to stop and app if they want to look up values from the WS.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of sidwelle
sidwelle
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Daniel Pineault
Daniel Pineault

you'd have to post your workbook for us to take a closer look at.