Positioning a user form

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
690
Office Version
  1. 365
Platform
  1. Windows
How do I get a user form to appear at the bottom and center of the screen no matter what the screen resolution is?
I use it on my laptop and my desktop and they have different screen resolutions which I can't make the same.

I get it to open at the bottom but always below the sheet bottom. It is below the task bar when it opens.

I know you can move the user form but many others do not.

Thank you
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
This code, placed in the form's code module, will center the form on the monitor. You'll have to test it to see how it handles your resolution issue. You can play around with the positioning parameters to position it to your liking.

VBA Code:
Private Sub UserForm_Activate()
    With Me                           ' Center Screen on whatever monitor Excel is running on
        .StartUpPosition = 0
        .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
        .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)

        If .Height > Application.Height Then
            .ScrollHeight = .Height
            .Width = .Width * 1
            .Height = .Height * 0.8
            .Zoom = 100
            .Top = .Top + 60
            Me.KeepScrollBarsVisible = fmScrollBarsVertical
            Me.ScrollBars = fmScrollBarsVertical
        End If
    End With
End Sub
 
Upvote 0
Thanks Dave but that's a little too heavy for me... Must be an easier way
 
Upvote 0

Forum statistics

Threads
1,214,593
Messages
6,120,435
Members
448,962
Latest member
Fenes

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