Hi, the code below is working, but there is a small problem with it. I have the data populate a ListBox, but I want the data to populate a ListView. Can someone help with this?
I tried to change this code to ListView, but it would not work. So I need someones help with this VBA.
Sorry again, I am a beginner to ListView, and I like it a lot, so it would be very appreciative if someone could help me.
Thank you.
I tried to change this code to ListView, but it would not work. So I need someones help with this VBA.
Code:
Private Sub CommandButton1_Click()
Call Display
End Sub
Code:
Private Sub UserForm_Initialize()
rTABLE6 = "Table6"
TblDB = Range(rTABLE6).Value
ColNR = UBound(TblDB, 2)
Set d = CreateObject("scripting.dictionary")
For i = LBound(TblDB) To UBound(TblDB)
d(TblDB(i, 4)) = ""
Next i
Me.ChoiceListBox1.List = d.keys
Set d = CreateObject("scripting.dictionary")
For i = LBound(TblDB) To UBound(TblDB)
d(TblDB(i, 6)) = ""
Next i
Me.ChoiceListBox2.List = d.keys
Set d = CreateObject("scripting.dictionary")
d.comparemode = vbTextCompare
For i = LBound(TblDB) To UBound(TblDB)
d(TblDB(i, 7)) = ""
Next i
Me.ChoiceListBox3.List = d.keys
Me.ListBox1.ColumnCount = ColNR
Call Display
End Sub
Code:
Sub Display()
Dim Liste(), ok(1 To 3)
n = 0
For i = LBound(TblDB) To UBound(TblDB)
For o = 1 To 3: ok(o) = False: Next o
p = 0
For Each c In Array(4, 6, 7)
p = p + 1
s = 0
For j = 0 To Me("ChoiceListBox" & p).ListCount - 1
If Me("ChoiceListBox" & p).Selected(j) Then s = s + 1
Next j
If s = 0 Then
ok(p) = True
Else
For j = 0 To Me("ChoiceListBox" & p).ListCount - 1
If Me("ChoiceListBox" & p).Selected(j) Then
If TblDB(i, c) = Me("ChoiceListBox" & p).List(j) Then ok(p) = True
End If
Next j
End If
Next c
If ok(1) And ok(2) And ok(3) Then
n = n + 1
ReDim Preserve Liste(1 To ColNR, 1 To n)
For k = 1 To ColNR
Liste(k, n) = TblDB(i, k)
Next k
End If
Next i
If n > 0 Then Me.ListBox1.Column = Liste Else Me.ListBox1.Clear
End Sub
Sorry again, I am a beginner to ListView, and I like it a lot, so it would be very appreciative if someone could help me.
Thank you.