ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to set focus back to sheet after showing a user form (https://www.excelbanter.com/excel-programming/272301-re-how-set-focus-back-sheet-after-showing-user-form.html)

Stephen Bullen

How to set focus back to sheet after showing a user form
 
Hi Les,

I have a modeless UserForm which opens on a DoubleClick event -
working fine. How can I do this but have the focus remain with the
ActiveCell? Or, alternatively, have the focus leave the newly
opened UserForm?


Presumably you're cancelling the BeforeDoubleClick? If so, one
solution is to specifically reactivate the Excel window:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

UserForm1.Show vbModeless
AppActivate Application.Caption
Cancel = True

End Sub


Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk



All times are GMT +1. The time now is 09:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com