Selected Answer
I think that your issue might be related to zoom level that is on high resolution screens, which messes with proportions for some programs.
If this is the case, you could set things according to the size of excel using Application.Width and Application.Height, or you could use a more complex setup to dynamically size it that might work that I found here.
In case that link stops working, the code from it is here:
Option Explicit
'Function to get screen resolution
#If VBA7 Then
Private Declare PtrSafe Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As LongPtr) As Long
'Functions to get DPI
Private Declare PtrSafe Function GetDC Lib "user32" (ByVal hwnd As LongPtr) As Long
Private Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hDC As LongPtr, ByVal nIndex As LongPtr) As Long
Private Declare PtrSafe Function ReleaseDC Lib "user32" (ByVal hwnd As LongPtr, ByVal hDC As LongPtr) As Long
#Else
Private Declare Function GetSystemMetrics32 Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long
'Functions to get DPI
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
#End If
Private Const LOGPIXELSX = 88 'Pixels/inch in X
Private Const POINTS_PER_INCH As Long = 72 'A point is defined as 1/72 inches
'Return DPI
Public Function PointsPerPixel() As Double
Dim hDC As Long
Dim lDotsPerInch As Long
hDC = GetDC(0)
lDotsPerInch = GetDeviceCaps(hDC, LOGPIXELSX)
PointsPerPixel = POINTS_PER_INCH / lDotsPerInch
ReleaseDC 0, hDC
End Function
Private Sub UserForm_Initialize()
Dim add_file_btn As CommandButton
Dim w As Long, h As Long
w = GetSystemMetrics32(0) ' Screen Resolution width in points
h = GetSystemMetrics32(1) ' Screen Resolution height in points
With Me
.StartUpPosition = 2
.Width = w * PointsPerPixel * 0.5 'Userform width= Width in Resolution * DPI * 50%
.Height = h * PointsPerPixel * 0.5 'Userform height= Height in Resolution * DPI * 50%
End With
End Sub
The code was posted by Lo Bellin. I have no idea if its his code or not, but giving him credit since he posted it.
Update
You are making a uesrform with a lot of controls inside of it and you will also have to change the size of the controls as it seems that you cannot have them auto-fit for changing screen sizes. Based on your screen shots, this seems to be the issue.
Ron de Bruin is an amazing guy who has a page on resizing userforms and controls that should help you.
That page should have what you need and the relevant code is this part:
With Me
'Change controls/font on the userform
For Each ControlOnForm In .Controls
With ControlOnForm
.Top = .Top * SizeCoefForMac
.Left = .Left * SizeCoefForMac
.Width = .Width * SizeCoefForMac
.Height = .Height * SizeCoefForMac
On Error Resume Next
.Font.Size = .Font.Size * SizeCoefForMac
On Error GoTo 0
End With
Next
End With
This shows you how to loop through the controls and change their size. You would replace .Width *SizeCoefForMac to something like this from the code that you posted: w * PointsPerPixel * 0.82
This should help getting the controls now "auto-resized" for the userform.