Search code examples
excelvbaresizeuserformmultipage

VBA UserForm Dynamic Resize Event with Multipages


Good Morning!

I started off by reading this :

http://www.andypope.info/vba/resizeform.htm

And while this was very informative, I was wondering if someone one would be able to point me in the right direction to help being able to solve my inquiry. I want to dynamically set height & width values of a userform depending on what multipage selected (presumably by click event). Would it be something like this?

 Sub pageX_click

 height.value = 23
 width.value = 50

 End Sub

I assume it might be more complicated than that, but if someone would be willing to point me in the right direction I can tinker till i find the correct solution.

Other question- due to the differing sizes, would I need to statically set which pages is opened each time? That way i dont get random size issues/errors?


Solution

  • Here is the solution- it was literally as simple as I thought

     Private Sub MultiPage1_Change()
    
     If MultiPage1.Value = 0 Then
         ToolBoxForm.Height = 560.25
         ToolBoxForm.Width = 652.5
     End If
    
     'lather, rinse, repeat for each page
    
     End Sub