It is a bit complicated, but it is something that can be done.
In the "Private Sub UserForm_Initialize ()" routine, add this as the last line:
Private Sub UserForm_Initialize() . . . . . . . . . . Application.OnTime Now(), "MoveFocusToWorksheet" End Sub
In any of the common code modules (add one if you don't have them), declare an API function:
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
In any of the general code modules (maybe, in the case of the API declaration), add this routine:
Public Sub MoveFocusToWorksheet() Dim Dummy As Long ThisWorkbook.Worksheets("Sheet1").Activate ' "Sheet1" here is the tab name of the sheet you want to move focus to. _ Or simply use then: With shtABC.Activate _ where "shtABC" being the worksheet CodeName, _ same as ThisWorkbook.Worksheets("Sheet1").CodeName, _ same as the sheets module name showing in the Project Explorer panel. Dummy = SetForegroundWindow(Application.hwnd) End Sub
source share