mperrah
08-03-2015, 04:13 PM
Hello VBAExpress community,
I'm working on a Calendar project and have hit a stumbling block.
I have a userform with a listbox that gets populated from a sheet range when the userform initializes.
On the form we can add items to the listbox.
I am attempting to build an array of the new ListCount, but only get my original list.
I can remove from the list and the removal is reflected, but additions are disregarded.
If any one can see what I'm missing I would appreciate the illumination:
Sub insertBills_UF()
Dim a, b, r, c, x, I, J As Long
Dim lbCnt As Integer
Dim wsNC, wsB As Worksheet
Dim aBills()
Set wsNC = Sheets(Sheets.Count)
Set wsB = Sheets("Bills")
lbCnt = 0
lbCnt = CalendarOpts.lbBills.ListCount - 1
ReDim aBills(0 To lbCnt, 0 To 2)
For a = 0 To lbCnt
aBills(a, 0) = CalendarOpts.lbBills.List(a, 0)
aBills(a, 1) = CalendarOpts.lbBills.List(a, 1)
aBills(a, 2) = CalendarOpts.lbBills.List(a, 2)
Next a
With wsNC
For b = 0 To lbCnt
For r = 3 To 38 Step 6
For c = 1 To 7
If .Cells(r, c) = aBills(b, 2) Then
For x = 1 To 5
If .Cells(r + x, c).Value = "" Then
.Cells(r + x, c).Value = aBills(b, 0) & "-" & aBills(b, 1)
Exit For
End If
Next x
End If
Next c
Next r
Next b
End With
End Sub
I'm working on a Calendar project and have hit a stumbling block.
I have a userform with a listbox that gets populated from a sheet range when the userform initializes.
On the form we can add items to the listbox.
I am attempting to build an array of the new ListCount, but only get my original list.
I can remove from the list and the removal is reflected, but additions are disregarded.
If any one can see what I'm missing I would appreciate the illumination:
Sub insertBills_UF()
Dim a, b, r, c, x, I, J As Long
Dim lbCnt As Integer
Dim wsNC, wsB As Worksheet
Dim aBills()
Set wsNC = Sheets(Sheets.Count)
Set wsB = Sheets("Bills")
lbCnt = 0
lbCnt = CalendarOpts.lbBills.ListCount - 1
ReDim aBills(0 To lbCnt, 0 To 2)
For a = 0 To lbCnt
aBills(a, 0) = CalendarOpts.lbBills.List(a, 0)
aBills(a, 1) = CalendarOpts.lbBills.List(a, 1)
aBills(a, 2) = CalendarOpts.lbBills.List(a, 2)
Next a
With wsNC
For b = 0 To lbCnt
For r = 3 To 38 Step 6
For c = 1 To 7
If .Cells(r, c) = aBills(b, 2) Then
For x = 1 To 5
If .Cells(r + x, c).Value = "" Then
.Cells(r + x, c).Value = aBills(b, 0) & "-" & aBills(b, 1)
Exit For
End If
Next x
End If
Next c
Next r
Next b
End With
End Sub