'VBA UserForm Frame ScrollTop function not working from class function
This should be a simple task and I've been coding in VBA for 10+ years but I cannot seem to get this to work. I have a UserForm with a MultiPage (with 2 pages). I am just working on the first page (Pages(0)), which has a Frame on it. just outside the frame are dynamically added labels (A - Z) and I have made a class to handle the onclick WithEvents. When the label is clicked I want the Frame to 'ScrollTop' to the corresponding name that starts with that letter. Inside the frame is many checkboxes with users names.
Here is what the form looks like.
Here is the class event handler when the user clicked a label (Letter A - Z)
Option Explicit
Public WithEvents LetterClick As MSForms.Label 'A - Z Letters on report output userform (to scroll the frame down to the declarant name start letter)
Dim Ctrl As Control
Private Sub LetterClick_Click()
With form_report_output_menu.MultiPage1.Pages(0).Frame1
For Each Ctrl In .Controls
If TypeName(Ctrl) = "CheckBox" Then
Debug.Print Ctrl.Caption
If Mid(Ctrl.Caption, 1, 1) = LetterClick.Caption Then
.ScrollTop = Ctrl.Top: Exit For
End If
End If
Next Ctrl
End With
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

