Adding controls to each page in a multipage form

M

michael fuller

Hi All,

I was wondering if there was anyone out there who can help me?

I have a worksheet with Group names populated in Coloumn "A"

A B

1 Group1 Value 1
2 Group2 Value 2
etc

the cell "A1" has a name defined as "Start"

I have wirtten come code that will allow this list to expand as required ie.
more groups are added.
and another piece that will display a form with a multipage create a new
page for each entry in coloum "A". with the group name as the caption.

Now I am stuck.... I cannot work out how to add a textbox to each of the
pages as it is created. The idea being that the box will display the data
contained in coloumn "B"

Having consulted the "Help" file I am now totally confused especially as the
code provided within does not seem to work when I create the example.
The code I am using is as follows

Sub test()

Dim name As String
Dim counter As Integer
counter = 0
Range("start").Select
Do Until ActiveCell = ""
Range("offset(start," & counter & ",0)").Select
If ActiveCell <> "" Then
name = ActiveCell
UserForm1.MultiPage1.Pages.Add (name)
'
' Code to set up pages goes here (I think)
'
'
End If
counter = counter + 1
Loop
UserForm1.Show

End Sub

Can anyone Help me please???

Regards and Thanks

Mick
 
B

Bob Phillips

Is this what you want

Dim sName As String
Dim counter As Integer
Dim oMP As MultiPage
Dim NewButton As MSForms.TextBox

counter = 0
Set oMP = UserForm1.MultiPage1
With Range("start")
Do Until .Offset(counter, 0).Value = ""
sName = .Offset(counter, 0).Value
If counter < 2 Then
oMP.Pages(counter).Caption = sName
Else
oMP.Pages.Add (sName)
End If
Set NewButton =
oMP.Pages(counter).Controls.Add("Forms.Textbox.1")
NewButton.name = "txt" & sName
NewButton.Text = .Offset(counter, 1).Value
NewButton.Left = 20
NewButton.Top = 20
counter = counter + 1
Loop
End With
UserForm1.Show


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
M

michael fuller

Hi Bob,

Thanks for the reply. Unfortunatly I get an "Invalid procedure call or
argument" error with the following line

oMP.Pages(counter).Caption = sName

I am using Excel 2000... would this account for the error?

Regards and Thanks

Mick
 
B

Bob Phillips

Mick,

I have just loaded up Excel 2000 and that code works fine for me there.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
B

Bob Phillips

Why don't you post me your workbook to look at?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top