How to prevent Excel UserForm from shrinking/expanding autonomously?

excel combo box text shrinks
vba to automatically resize userform depending on screen resolution
make userform full screen
dynamically resize userform vba
excel vba userform maximum size
excel vba autoscalemode
excel vba buttons keep moving
vba get height of userform

My Excel UserForms contain a variety of objects, including text boxes, combo boxes, radio buttons, etc. The UserForm and the objects on the UserForm shrink and expand when my laptop is on a docking station and the VBA window is open on a larger monitor.

When I access the UserForm editor from the Forms tab in VBA, I can drag the UserForm resize handles and the objects in the UserForm will immediately snap back to their original state, but I want to do this programmatically so that the end user will not deal with shrunken/expanded UserForms.

I have tried resizing the UserForm upon opening (UserForm_Initialize), but it seems as if the shrinking/expanding takes place while the UserForm is not active, meaning that my UserForm resizing only acts to return the UserForm to its shrunken/expanded state and not its original state.

Sub UserForm_Initialize()

 Call ResizeUserform(Me)

End Sub

Sub ResizeUserform(UserForm_Name As Object)

 UserForm_Name.Width = UserForm_Name.Width + 0.001
 UserForm_Name.Width = UserForm_Name.Width - 0.001

 UserForm_Name.Height = UserForm_Name.Height + 0.001
 UserForm_Name.Height = UserForm_Name.Height - 0.001

End Sub

I had a similar issue, ever time the program opened the Login user form would be smaller than the last time. It only did it on my lap top with extra monitors. I finally used

Private Sub UserForm_Initialize()
   With Userform
      .Width = Application.Width * 0.3
      .Height = Application.Height * 0.6    
   End With
End Sub 

in the userforms code and it kind of stopped meaning it no longer showed the user the change but if I open the VBA it had changed size on the Height and Width but since it was only in the VBA and the user didn't have to try and enter a password in a mini box its fine.

Userforms shrink on successive openings of an Excel file, Hi, I've run across the weirdest bug ever and wonder if anybody recognizes it and have any input. In an Excel VBA-project several years in the  It would seem that if the userform editor window is left open in the VBA editor, Excel somehow screws it up on saving. The workaround is simple (albeit a bit cumbersome): If a form gets corrupted this way, simply resize it. This will make it snap back to its proper rendition. Then make sure to close the userform edit window before saving.

Don't make the form maximized. "Maximized" means you don't know at design-time what the size of the form will be, because you're making that depend on what monitor size it's being displayed in.

Larger monitor = larger maximized form, that's by design.

If you don't want the form to resize automatically when it's displayed in a different-size monitor, then don't maximize it.

Alternatively, handle the form's Resize event, and programmatically move each control where it needs to be relative to the bottom-right edge. Note, that's tricky and extremely annoying code to write, especially if the form is any kind of complicated. Much simpler to just not have a maximized form.

How to control the size of a UserForm in Excel, This article describes how to control the size of a UserForm in Microsoft Excel. a support scam. Keep in touch and stay productive with Teams and Microsoft 365​, even when you're working remotely. Learn more Expand your Office skills. Call ResizeWindowSettings (myUserForm, True) To turn off resizing, use the following. Call ResizeWindowSettings (myUserForm, False) Just replace myUserForm with the name of your form, or use Me if within the UserForm’s code module.

this operation can also be done with a loop. I used the button to increase and decrease the height of userform. I created a loop and assigned it to the button.At the same time there was a nice animation. You set a height value, when the button is pressed, the userform becomes longer if the height is less than this value, and the userform becomes shorter if it is larger. Codes:

Private Sub CommandButton4_Click()
Dim X, d, yuk, mak As Integer
For X = 1 To 100
If e = 0 Then
d = d + 10
yuk = 242
mak = 342
d = d - 10
yuk = 345
mak = 245
End If
UserForm2.Height = yuk + d
If UserForm2.Height >= mak And e = 0 Then GoTo 10
If UserForm2.Height <= mak And e = 1 Then GoTo 20
10 CommandButton4.Caption = "<"
e = 1
ListBox1.ListIndex = 0
Exit Sub
20 CommandButton4.Caption = ">"
e = 0
ListBox1.ListIndex = 0
End Sub

It's video :

Source and Example file here

[Fix] Excel UserForm Appears Shorter and Narrower Than Previous , Assuming you're working on Excel 2016, and you set the Height and Width object, and then select and drag the corner mark to expand the Userform size. Now  Prevent a userform from closing when the user clicks the x-button by using VBA in Microsoft Excel In this article, we will show how to disable the x-button on the userform by using VBA. In this example, we have created a userform which can be activated by clicking the run button on the worksheet.

I had a similar problem. The only thing that worked for me was going into the Advanced Options of Excel and checking the box, "Disable hardware graphics acceleration." I wasted several hours trying to find this. I hope this helps someone else!

How to prevent animated div from expanding several times after , How to prevent animated div from expanding several times after several clicks I How to prevent Excel UserForm from shrinking/expanding autonomously? Lock cell width and height from resizing with protecting the worksheet. The only way for you to lock the cell width and height is to protect the worksheet with password. Please do as follows. By default, all cells in a worksheet are locked. If you want to keep cells editable after locking the cells’ width and height, please unlock them in

Don't leave your form's dimensions ambiguous or prone to logic circularity (i.e. as a function of itself); set them up before loading/showing.


   'where XX and YY are integer constants:
   With YourFormName
    end with

If you absolutely need to incur in circular statements, do it indirectly by storing your calculated variable in a global/local variable, and then proceed to declare its properties (i.e. YourFormName.width=variable)

Good luck!.

Model shrinking during animation + Animation not playing in full I'm , excel, 12.01.2020 18:51, quintencoffman2. How to prevent Excel UserForm from shrinking/expanding autonomously? Answers: 3. continue. image. javascript  Is there a way for the userform to "shrink" proportionally to fit the screen? Or is there a way to make a scroll bar so that the user can scroll down if it doesn't fit the screen. I made this userform on a 17 inch screen and when i open it on a 15 inch laptop screen somethings aren't appearing. I desperately need help to solve this.

Excel: Pivottable slicers: Configuring your Slicers, Formula Wrapper · Import textfiles · Inventory System · Keep Userform On Top · Listbox Like any style in Excel 2010, these adhere to the theme you've selected​. This makes it easy to keep your workbook design tidy and consistent. The only way to make the slicers work independently again is by using the Undo button. This method will guide you to format cells to prevent cell contents from overflowing in Excel. Please do as follows: 1. Select the column/list that you will prevent cell contents from overflowing, right click and select the Format Cells from the right-clicking menu. 2.

Auto fit a VBA User form in window screen, Hello Friends, In this video you will learn how to auto fit a VBA user form in window screen Duration: 10:27 Posted: 1 Feb 2018 '***EXCEL BUG WORKAROUND***** 'When a command button's TakeFocusOnClick property is set to False, as it is for this button, the 'displayed size of its caption text can sometimes shrink or grow with each button-click even 'though the font size is not actually changed (i.e. similar to a zoom operation on the caption 'text only).

Year Long Schedule, To avoid this, I've also provided automatic formatting for the various calendar I really like the idea of a UserForm and that was my original plan but have no idea the Full Command worksheet - this will shrink/expand that worksheet to show of being able to sort the Full Command independently of the department sheets,  Hi Viper. An ActiveX ListBox Control has a IntegralHeight Property, which by default is set to True. Go into the Properties Window of the ListBox and set it to False.This should stop the Auto re-sizing.

  • Forms don't normally shrink or expand autonomously - quite the contrary, making a "reactive" UI in MSForms is an absolute nightmare, because the UI framework doesn't help with layout whatsoever. Is the form maximized? What is the BorderStyle?
  • You can try handling the Resize event and see if you can absolute-position each control in there (e.g. Me.TextBox1.Left = Me.Width - RightMargin - Me.TextBox1.Width, etc.)... good luck!
  • @MathieuGuindon I have tried both "None" and "Single" for BorderStyle, and it seemed to have no effect on the shrinking/expanding. Also, I don't give the user the option to resize the form, so it should always be maximized.
  • Having a maximized form is giving the option to resize: all one needs is... a second monitor with a different size. The form should fire its Resize event when it is moved to another monitor and resized.
  • Either you handle Resize and make the form look nice regardless of what monitor size it's displayed on, ....or you make it not maximized - that way it'll always be the same size, regardless of monitor size.
  • Try to avoid so called Spaghetti code with GoTo commands inherited from former BASIC times - that's not the state of the art, as you risk losing track of any inner structure; only error handling is commonly accepted by such routines. BTW Dim X, d, yuk, mak As Integer will declare only mak as Integer, the neglected variables X, d,yuk are interpreted as Variant as they aren't declared expressly as Integer: MS Help states: "If you don't specify a data type or object type, and there is no Def_type_ statement in the module, the variable is Variant by default."