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
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Andy Pope

Active Member
Joined
Dec 31, 2003
Messages
349
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.
 
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,168,127
Messages
5,857,525
Members
431,883
Latest member
Hien

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