add controls on the fly/dynamically

jinx_uk_98

Board Regular
Joined
Jul 3, 2005
Messages
105
Hi All.

I use this code to rename the tabs of multipage control on a userform.

Sub page()

For Each Cell In Sheets("Data").Range("major_streams")
frm_daily_entry.MultiPage1.Pages.Add Cell.Text
Next

End Sub

The problem I have is that when creating the tabs on the fly I also have to create other controls on the fly too, specifically Labels & textboxes.

The Labels & Textboxes will be defined by looking up the caption of the current tab (on sheet1) and adding however many label/Textboxes that are required (one for every item under the heading on the sheet).

Anyone have any ideas?

thanks

Kevin
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Switching on/off

Hi Kevin,

sounds like a tough one... I think the easiest way around would be to create a userform, put the items (like boxes, buttons etc.) on their place and then use the code to change the caption, visability and whether it is switched on or not...
I don't know if you are familiar with Access, but I'm thinking off more or less the same idea as a standard created menu in Access (the Switchboard).

Would that help you?

Greetz,

Koen
 
Upvote 0
Kevin

I'm not 100% sure what your question is but I think you probably want to look at the Add method of the Controls collection of the Userform/Page.

Also if you are adding the controls to the new pages of the multipage you should probably set a reference to the new page when you add it.
Code:
Dim mp As Page

    Set mp = MultiPage1.Pages.Add("New Page")
    mp.Controls.Add "Forms.Textbox.1"
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,443
Members
448,898
Latest member
drewmorgan128

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