RockandGrohl
Well-known Member
- Joined
- Aug 1, 2018
- Messages
- 790
- Office Version
- 365
- Platform
- Windows
Hi guys, hopefully a quick one where I am just getting syntax confused here.
In a column I have a list of string entries on each line, such as "A1" on one line, A2 in the line below, C1 in the line below, etc.
I also have a userform that has a lot of checkboxes, and I'm trying to enable them based on the strings contained in this column.
For example, my checkbox names are handily like "A1_Checkbox", "A2_Checkbox" etc.
So I was thinking, I will rattle down the list of strings and disable all checkboxes on userform initialization, then enable them one by one based on what I find.
RegCol is the column where the strings are held.
Hopefully you see the kind of logic I was going for there haha. Whether it works or not is another matter.
In a column I have a list of string entries on each line, such as "A1" on one line, A2 in the line below, C1 in the line below, etc.
I also have a userform that has a lot of checkboxes, and I'm trying to enable them based on the strings contained in this column.
For example, my checkbox names are handily like "A1_Checkbox", "A2_Checkbox" etc.
So I was thinking, I will rattle down the list of strings and disable all checkboxes on userform initialization, then enable them one by one based on what I find.
VBA Code:
Private Sub UserForm_Initialize()
Dim regcol As Long
Dim lastrow As Long
Dim i As Long
Dim chkBox As MSForms.CheckBox
CritPanel.A1_Checkbox.Value = False
CritPanel.A2_Checkbox.Value = False
CritPanel.A3_Checkbox.Value = False
CritPanel.A4_Checkbox.Value = False
CritPanel.A5_Checkbox.Value = False
CritPanel.A6_Checkbox.Value = False
CritPanel.B1_Checkbox.Value = False
CritPanel.B2_Checkbox.Value = False
CritPanel.B3_Checkbox.Value = False
CritPanel.C1_Checkbox.Value = False
CritPanel.C2_Checkbox.Value = False
CritPanel.C3_Checkbox.Value = False
CritPanel.D1_Checkbox.Value = False
CritPanel.D2_Checkbox.Value = False
Set ppl = Worksheets("Price Panel Lines")
ppl.Activate
regcol = 29
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To lastrow
CritPanel." & cells(i,regcol).value & "_Checkbox".value = true
Next i
End Sub
RegCol is the column where the strings are held.
Hopefully you see the kind of logic I was going for there haha. Whether it works or not is another matter.