jparfitt87
New Member
- Joined
- Jul 13, 2012
- Messages
- 23
Hi everyone hope you can help with this one,
I'm starting to tidy up my code and make is shorter instead of repeating things multiple times, so i have been learning about For loops.
I have a userform with several multipages, each page has 5 questions, which are pulled through from an excel page.
The code i was using (and which is repeated 50 times) to do this was:
LabelQ1AV.Caption = Range(FrmScope.LabelQ1AV.Name)
however I have found i can use:
Function Title()
Dim ctrl As Control
r = FrmScope.MultiPage1.Value
For Each ctrl In FrmScope.MultiPage1.Pages(r).Controls
If TypeName(ctrl) = "Label" Then
If Left(ctrl.Name, 5) = "Label" Then ctrl.Caption = Range(ctrl.Name).Value
End If
Next ctrl
End Function
The problem with the above code, and any code i've found so far, is that it only seems to work for the 1st page, when i click next the second page is blank when it should have 4 or 5 questions showing.
any help would be greatly appreciated
I'm starting to tidy up my code and make is shorter instead of repeating things multiple times, so i have been learning about For loops.
I have a userform with several multipages, each page has 5 questions, which are pulled through from an excel page.
The code i was using (and which is repeated 50 times) to do this was:
LabelQ1AV.Caption = Range(FrmScope.LabelQ1AV.Name)
however I have found i can use:
Function Title()
Dim ctrl As Control
r = FrmScope.MultiPage1.Value
For Each ctrl In FrmScope.MultiPage1.Pages(r).Controls
If TypeName(ctrl) = "Label" Then
If Left(ctrl.Name, 5) = "Label" Then ctrl.Caption = Range(ctrl.Name).Value
End If
Next ctrl
End Function
The problem with the above code, and any code i've found so far, is that it only seems to work for the 1st page, when i click next the second page is blank when it should have 4 or 5 questions showing.
any help would be greatly appreciated