Center Userform

Molden

Active Member
Joined
Jun 20, 2006
Messages
373
Hi,

I have some code that extends my userform depending on what is selected on a drop down box. But when I shrink the userform it is no longer in the center of the screen.

Does anyone no how to center a userform via code.

Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

Evagrius Ponticus

Well-known Member
Joined
May 24, 2007
Messages
1,467
Hi,

In the properties box, under the position title, check the "center screen" option - see if that works. You can also try

Code:
UserForm2.StartUpPosition = 2
 
Upvote 0

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
As a user I would find it very disconcerting if a UserForm moved on the screen when it was resized. In my view you should stick with the initial left and top positions, allowing for any increases in size.
 
Upvote 0

Molden

Active Member
Joined
Jun 20, 2006
Messages
373
it just looks a bit weird - one minute its in the center and next its more to the left.

Thanks for the advise though I will try the above code first.
 
Upvote 0

Forum statistics

Threads
1,191,273
Messages
5,985,690
Members
439,974
Latest member
sjoerdbosch

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