I am trying to populate a combo box using an arraylist. I used the following code but it doesn't seem to work.
Private Sub UserForm_Initialize()
Sheets("MSS").Select
Dim counter As Integer
Dim cmbox_opt As String
Dim array_cmbox As ArrayList
Set array_cmbox = New ArrayList
Dim last_row As Integer
Dim i As Integer
last_row = Range("B" & Rows.Count).End(xlUp).Row
For counter = 3 To last_row
cmbox_opt = Range("B" & counter).Value
If Not array_cmbox.Contains(cmbox_opt) Then
array_cmbox.Add cmbox_opt
End If
Next
For i = 1 To i = 1 + i
If array_cmbox.Contains(array_cmbox(i)) Then
Me.ComboBoxArea.AddItem array_cmbox(i)
End If
Next
'Ensure Window Dimensions'
With Me
.Width = 577
.Caption = "Master Sanitation Schedule Form v.1.0"
.Height = 274
End With
End Sub
However, if I just add the line
Me.ComboBoxArea.AddItem array_cmbox(2)
It does add the second item to the combo box from the ArrayList