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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Rijnsent

Well-known Member
Joined
Oct 17, 2005
Messages
1,338
Office Version
  1. 365
Platform
  1. Windows
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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,343
Office Version
  1. 365
Platform
  1. Windows
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"
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,524
Messages
5,832,258
Members
430,121
Latest member
Andy Becker

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
Top