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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

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,122,261
Messages
5,595,144
Members
413,971
Latest member
User786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top