I could use a second (or sixth... I wear glasses) set of eyes on this.
Ultimate goal is let user know when there are more than 5 if the same number in the 3rd column of a userform listbox....
I thought to build an array from the listbox,
pulling just unique values,
then compare the unique array items against the listbox items
and get a sum count for matches
then show a msgbox if any item has more than 5 matches...
after several tries this gets the farthest, but errors on "
a_lbBills(t, c) = .List(r, c)
Sub makeDupListInArray()
Dim t, r, c, x, lbCnt As Integer
Dim myLb
Dim a_lbBills()
Set myLb = CalendarOpts.lbBills
With myLb
t = 1
For r = 0 To .ListCount - 1
ReDim a_lbBills(0 To r, 0 To 2)
For c = 0 To 2
If .List(r, 2) <> .List(r + 1, 2) Then
'ReDim Preserve a_lbBills(0 To t, 0 To 2)
a_lbBills(t, c) = .List(r, c)
End If
Next c
t = t + 1
Next r
For x = 0 To UBound(a_lbBills)
For r = 0 To .ListCount - 1
If a_lbBills(x, 2) = .List(r, 2) Then
lbCnt = lbCnt + 1
End If
Next r
If lbCnt = 6 Then
.ListIndex = r
MsgBox ("Too Many bills on one day")
End If
Next x
End With
End Sub
any and all help is greatly appreciated
-mark