mardi 14 juillet 2020

How do I change the checkbox size of a UserForm in VBA when the the checkbox is generated within the code?

So I have this code within a userform

Sub UserForm_Initialize()

Dim i           As Long
Dim chkBox      As MSForms.CheckBox

On Error GoTo Error:
LastRow = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row

For i = 1 To LastRow
    Set chkBox = Me.Controls.Add("Forms.CheckBox.1", "CheckBox_" & i)
    chkBox.Caption = Worksheets("Sheet1").Cells(i, 1).Value
    chkBox.Left = ((i - 1) Mod 4) * 100 + 5
    chkBox.Top = 5 + Fix((i - 1) / 4) * 30
Next i
Error:
End Sub

When I run this code I get checkboxes based on values is from a row in Excel. It looks like this Screen shot of checkboxes

What I want to do is make the text box for the checkbox higher to make the entire field visible, but I can't figure this out. I am pretty new to VBA and really new to UserForms. Any help would be appreciated. Thanks ADS




Aucun commentaire:

Enregistrer un commentaire