loop controls through multipage & frame on userform

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
387
Office Version
  1. 2016
Platform
  1. Windows
hello
I have this form as in picture and it doesn't copy the values from controls to ranges in sheet
so what suggest to do that ?
VBA Code:
Private Sub CommandButton1_Click()
Dim lr As Integer
Dim ctrl As Control
With sheet1
lr = .Range("c" & Rows.Count).End(xlUp).Row + 1

r = UserForm1.MultiPage1.Value
For Each ctrl In UserForm1.MultiPage1.Pages(r).Controls
If TypeName(ctrl) = "textbox" & "combobox" Then

.Range("a" & lr) = Me.TextBox1
.Range("B" & lr) = Me.TextBox2

.Range("c" & lr) = Me.ComboBox1
End If
Next ctrl
End With
End Sub
1.JPG



thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

Use below code:

VBA Code:
Private Sub CommandButton1_Click()
    Dim lr As Integer
    Dim ctrl As Control
    With Sheets("Sheet1")
        lr = .Cells(Rows.Count, "C").End(xlUp).Row + 1
        
        r = UserForm1.MultiPage1.Value
        For Each ctrl In UserForm1.MultiPage1.Pages(r).Controls
            If TypeName(ctrl) = "TextBox" Or TypeName(ctrl) = "ComboBox" Then
                .Range("a" & lr) = Me.TextBox1
                .Range("B" & lr) = Me.TextBox2
                .Range("c" & lr) = Me.ComboBox1
            End If
        Next ctrl
    End With

End Sub
 
Upvote 0
Solution
My Pleasure. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,605
Messages
6,120,473
Members
448,967
Latest member
visheshkotha

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