WindsorKnot
Board Regular
- Joined
- Jan 4, 2009
- Messages
- 160
Hi,
I have a series of checkboxes from a Userform, when if checked, populate certain cells, and if cheked, populate other cells.
The code works fine without an array, but needs to be simplified. The array portion just rewrites over my the previous selection, which is causing the current issue.
Any input would be appreciated.
Thanks!
Private Sub cmdOK_Click()
' Populate the Arrary; Chk is checkbox and MTG is string to populate
MyArray = Array(HCRChk, HCRMTG, STWChk, STWMTG, CEMChk, CEMMTG)
For j = 1 To 3
For i = 0 To UBound(MyArray) - 1 Step 2
'Cycle through Array and populate Cells based on user-input
If MyArray(i) Then Cells(j + 4, 5).Value = MyArray(i + 1) Else Cells(j + 4, 6).Value = MyArray(i + 1)
'If STWChk Then Cells(6, 5).Value = STWMTG Else Cells(6, 6).Value = STWMTG
'If CEMChk Then Cells(7, 5).Value = CEMMTG Else Cells(7, 6).Value = CEMMTG
Next i
Next j
Me.Hide
End Sub
I have a series of checkboxes from a Userform, when if checked, populate certain cells, and if cheked, populate other cells.
The code works fine without an array, but needs to be simplified. The array portion just rewrites over my the previous selection, which is causing the current issue.
Any input would be appreciated.
Thanks!
Private Sub cmdOK_Click()
' Populate the Arrary; Chk is checkbox and MTG is string to populate
MyArray = Array(HCRChk, HCRMTG, STWChk, STWMTG, CEMChk, CEMMTG)
For j = 1 To 3
For i = 0 To UBound(MyArray) - 1 Step 2
'Cycle through Array and populate Cells based on user-input
If MyArray(i) Then Cells(j + 4, 5).Value = MyArray(i + 1) Else Cells(j + 4, 6).Value = MyArray(i + 1)
'If STWChk Then Cells(6, 5).Value = STWMTG Else Cells(6, 6).Value = STWMTG
'If CEMChk Then Cells(7, 5).Value = CEMMTG Else Cells(7, 6).Value = CEMMTG
Next i
Next j
Me.Hide
End Sub