Search This Blog

Monday 13 August 2012

TO FIT THE SIZE OF USERFORM TO YOUR EXCEL WINDOW

Paste the below code in UserForm_Activate procedure and run. It will fit the size of userform to your excel window.


Private Sub UserForm_Activate()
ActiveWindow.WindowState = xlMinimized
With Application
    Me.Top = .Top
    Me.Left = .Left
    Me.Height = .Height
    Me.Width = .Width
End With
End Sub

1 comment:

  1. It was fantastic experience for me to use this code to fit user form on my screen. One more help please that when we maximize userform by vba code it done well but other controls like textboxes comboboxes commandbuttons etc remain their actual size and all these controls also remain at left and up side of screen, so any idea how we can show all controls in center of screen whit above code?

    ReplyDelete