Resize userform VBA

agfac

New Member
Joined
Dec 16, 2013
Messages
20
Hi,

I made an userform on a PC with 1920x1080 resolution but I want to test it on other PC with a lower resolution.

What is the best solution?

Thanks
 
Last edited:

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I don't know the best, but try this code
Code:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
'---------------------------------
Public Function GetSR() As Variant
GetSR = Array(GetSystemMetrics(0), GetSystemMetrics(1))
End Function
'-----------------
Sub ResizeForm_R1()
' Adjusts userform size to compensate for screen resolution changes.

'Call function to get actual screen resolution
varSize = GetSR
resX = varSize(0)
resY = varSize(1)

'Determine ratio of actual screen resolution to
'the original or base resolution.
RatioX = resX / UserForm1.Width
RatioY = resY / UserForm1.Height
RY = 3.5
RX = 1.66

Fact = 1 ' 1 = full screen , 2 for half
'Adjust userform magnification and size.
UserForm1.Zoom = 100 * RatioX / 1.66 / Fact
UserForm1.Width = UserForm1.Width * RatioX / RX / Fact
UserForm1.Height = UserForm1.Height * RatioY / RY / Fact
UserForm1.Show
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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