Excel Macro - UserForm Control

ranouilh

New Member
Joined
Apr 26, 2005
Messages
16
I have a UserForm that is all ways showing in my spreadsheet and I use it run several macros that manipulate data in the sheets. After running one of the macros I would like to make the sheet active but the UserForm stays active causing me to have to click my mouse on the sheet to activate the sheet. Is there a way in the VBA code of my macro to activate the sheet but keep the UserForm visible? This way when the macro completes I will not have to click my mouse on the cell I can just start typing in data.
 

Some videos you may like

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

XLGibbs

Well-known Member
Joined
Feb 25, 2005
Messages
2,446
In the properties of the Form in VB editor you can change the display to vbModeless (it is probably set to vbModal).

The actual syntax may be slightly different, but a modeless Form display keeps the Form visible and allows sheet interaction

Maybe?
 
L

Legacy 98055

Guest
Not sure if you can without using an API function. Place this in your userform in the general declarations section..

Code:
Private Declare Function SetFocus Lib "user32" (ByVal hwnd As Long) As Long

Call it at the end of your macro as such...

Code:
SetFocus Application.hwnd

Depending on the version of your Office software, "Application.hwnd" may not be available. If not, post back and we'll work around it with another function or two.

Tom
 

Watch MrExcel Video

Forum statistics

Threads
1,118,812
Messages
5,574,463
Members
412,595
Latest member
slim313
Top