Cycling through textboxes in a tab of a MultiPage control

craigyg

Board Regular
Joined
Dec 14, 2005
Messages
114
I have been using the following code for cycling through textboxes on a userform and dumping their values onto a temp worksheet:

i = 1
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Then
ThisWorkbook.Sheets("Temp Values").Cells(i, 1) = ctl.Value
i = i + 1
End If
Next ctl

I need to modify it now to just dump values for one tab within a multipage control on a userform (I have a multipage control with 9 tabs or so and 10 or so textboxes per tab). It should not dump values for any other tab than the one that I will specify in the code. How can I modify the For Each statement to tell the code to just look on the tab. Or is there another way to do this? Thanks.

- Craig
 

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Andy Pope

Board Regular, The other chart guy
Joined
Dec 31, 2003
Messages
348
You can specify the page upon which to look for controls.
Don't format the pages index is zero based.

Code:
    i = 1
    For Each ctl In MultiPage1.Pages(2).Controls
        If TypeName(ctl) = "TextBox" Then
            ThisWorkbook.Sheets("Temp Values").Cells(i, 1) = ctl.Value
            i = i + 1
        End If
    Next ctl
 

craigyg

Board Regular
Joined
Dec 14, 2005
Messages
114
Thank you

You are the Pope of excel , but you probably hear that all the time.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,381
Messages
5,547,613
Members
410,803
Latest member
lsweeney
Top