Problemer med at få vist data i en ListBox (VBA + UserForm)
Hej,Jeg har nedenstående kode som driller lidt. Mit problem består i, at jeg skal have vist hvis der er oprette en ny konto. Det kan jeg også få vist, men hvis de sidste 2 linje i mit dataområde er nye konti, så bliver de ikke vist i min listbox. Hvad har jeg lavet af fejl i koden?
pft.
Koden der henter konti der er nye:
Private Sub cmbNyKonto_Click()
Dim i As Long
Me.ListBox1.Clear
If Range("ErDerNykonto").Value = 0 Then
MsgBox "Der er ikke nogle nye konti der skal mappes op.", vbInformation, "Opmapning af nye konti"
Unload ufrNewAccount
Exit Sub
Else
'("A:A")
For i = 3 To Application.WorksheetFunction.CountA(NewAcount.Range("A:A"))
a = Len("Ny")
If Left(NewAcount.Cells(i, 10).Value, a) = Left("Ny", a) Then
Me.ListBox1.AddItem NewAcount.Cells(i, 1).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = NewAcount.Cells(i, 2).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = NewAcount.Cells(i, 6).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = NewAcount.Cells(i, 8).Value
Me.ListBox1.List(ListBox1.ListCount - 1, 4) = NewAcount.Cells(i, 10).Value
End If
Next i
End If
End Sub