Array in UserForm

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
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,224,396
Messages
6,178,389
Members
452,844
Latest member
Shebl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top