I have created a multipage with dynamic pages. When the userform is launched, the userform checks the values on a specific cell in a column if they are empty or not. then create a page for each of the non-empty cells.
Here is my code snippet
Private Sub UserForm_Initialize()
Dim i As Integer
Dim custDate As Date
Dim vID As String
'ActiveWorkbook.Worksheets("Sheet1").Activate
i = 0
custDate = DateValue(Now)
Range("A1").Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell.Value)
'MsgBox ActiveCell.Address
If custDate = ActiveCell.Value Then 'first column(A) are dates
MultiPage1.Pages.Add
MultiPage1.Pages(0).Controls.Copy 'page 1 is the reference page
i = i + 1 'row counter
ActiveCell.Offset(0, 2).Select 'go to column(C) on the same row where visit ids are located
vID = ActiveCell.Value
MultiPage1.Pages(i).Paste 'copy page 1 contents to new page for each row on the active worksheet
'I guess this is where you put the code to put values
'on a txtbox that was from the reference page which is page 1
ActiveCell.Offset(0, -2).Select 'go back to column(A) to check back dates
End If
ActiveCell.Offset(1, 0).Select 'move to the next row
Loop
MultiPage1.Value = i 'select the new page on the userform
End Sub
Now my problem is how to put the values from a cell to a textbox that was copied from the reference hidden page to the dynamically created new page. I just started programming VBA last night. I am an android applications developer, so it's kind of hard to adjust as of this moment.
MultiPage1.Pages(0).Controls.Copy
is this the textbox that you are copying? - Siddharth RoutExit For
When I work with Dynamic controls, I prefer not copying but recreating them from the scratch as that gives me more control over those objects. - Siddharth Rout