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.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
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?
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,426
Members
448,961
Latest member
nzskater

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
Back
Top