![]() |
How to set focus back to sheet after showing a user form
Hi Bill
I tried the ActiveSheet.Select in the various places, but none of them worked - stepping through the code passes those lines correctly but in all cases the UserForm just keeps the focus. Have tried all combinations that I can think of (ActiveCell.Activate etc etc ....... ) but nothing appears to remove the focus from the UserForm. Also, have tried everything in various places throughout the code that runs during the UserForm initialization etc. All I'm trying to do is to remove the single step where the user has to click on the sheet once to regain the focus before the cursor keys let them move cell to cell. By the way, it's Excel 2000 sp3 that I'm using. Thanks for your help. regards, -- Les Hay, Livingston. Scotland "Bill Lunney" wrote in message ... Using Excel 2003 beta just now but standard behaviour is the worksheet keeps focus when displayed modeless. I tried it using: Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) UserForm1.Show vbModeless End Sub However if you're not getting this behaviour in your version just add something like: Private Sub UserForm_Initialize() ActiveSheet.Select End Sub to the init event of your form. That should reactivate the worksheet and subsequently the activecell. -- Regards, Bill Lunney www.billlunney.com "Les" wrote in message ... Hi 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? regards, -- Les Hay, Livingston. Scotland |
All times are GMT +1. The time now is 06:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com