Userform embed into frame

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
I know you can obviously put a frame with controls on a multipage Userform at the time of design, but can I move/show/display/embed a frame with its controls that I saved on another multipage in the same Userform as user makes various selections on the Userform?

Currently, I am placing multiple frames on a multipage tab but setting visible = false until the user selects what I want to trigger frameX.visible=true. I'd like to simply move the userform from a hidden multipage tab and onto the visible multipage tab.

WHY?
Because it is easier for me to store the frames on non-visible multipage tabs where I can access and modify instead of having to figure out where they are buried in the pile. Thanks
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I was initially going to say no, but then I thought this should be possible and after a little search I found this, which should get you going.

As I said I found the code - I have tested it with a two page userform, removed the line that creates a new tab (but left it in to show you) - the link the original post (stackoverflow from 2012 )is at the bottom.

I am now going to start using this idea in some of my smaller projects to see if it works for the business :)

Hid tab1 on load of form, pressed my button and it copied from tab1 to tab2 perfectly - then if I press my button again, it pastes another copy - slightly overlapping - but that's the standard copy paste where it tries not to sit directly on top of something that is already there... you may need some logic, to remove the iframe/refresh the tab...something to think about next week!

Happy weekend!


Code:
Option Explicit

Private Sub ToggleButton1_Click()
    Dim l As Double, r As Double
    Dim ctl As Control

[COLOR="#008000"]   ' MultiPage1.Pages.Add ' adds a new tab if you want it![/COLOR]

    MultiPage1.Pages(0).Controls.Copy
    MultiPage1.Pages(1).Paste

     For Each ctl In MultiPage1.Pages(0).Controls
        If TypeOf ctl Is MSForms.Frame Then
            l = ctl.Left
            r = ctl.Top
            Exit For
        End If
    Next

    For Each ctl In MultiPage1.Pages(1).Controls
        If TypeOf ctl Is MSForms.Frame Then
            ctl.Left = l
            ctl.Top = r
            Exit For
        End If
    Next
End Sub

https://stackoverflow.com/questions/10822450/copy-elements-from-one-page-to-another-in-multipage-with-vba-in-excel
 
Upvote 0
I was initially going to say no, but then I thought this should be possible and after a little search I found this, which should get you going.

As I said I found the code - I have tested it with a two page userform, removed the line that creates a new tab (but left it in to show you) - the link the original post (stackoverflow from 2012 )is at the bottom.

I am now going to start using this idea in some of my smaller projects to see if it works for the business :)

Hid tab1 on load of form, pressed my button and it copied from tab1 to tab2 perfectly - then if I press my button again, it pastes another copy - slightly overlapping - but that's the standard copy paste where it tries not to sit directly on top of something that is already there... you may need some logic, to remove the iframe/refresh the tab...something to think about next week!

Happy weekend!


Code:
Option Explicit

Private Sub ToggleButton1_Click()
    Dim l As Double, r As Double
    Dim ctl As Control

[COLOR=#008000]   ' MultiPage1.Pages.Add ' adds a new tab if you want it![/COLOR]

    MultiPage1.Pages(0).Controls.Copy
    MultiPage1.Pages(1).Paste

     For Each ctl In MultiPage1.Pages(0).Controls
        If TypeOf ctl Is MSForms.Frame Then
            l = ctl.Left
            r = ctl.Top
            Exit For
        End If
    Next

    For Each ctl In MultiPage1.Pages(1).Controls
        If TypeOf ctl Is MSForms.Frame Then
            ctl.Left = l
            ctl.Top = r
            Exit For
        End If
    Next
End Sub

https://stackoverflow.com/questions...age-to-another-in-multipage-with-vba-in-excel

Thanks let me know how your testing goes.
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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