rajesh2014
Member
I am creating Excel file, where i have 5 listboxes, each listbox is loaded with data from other sheet.
What i am doing is, If i selected a item in all listbox, macro is checking next sheet, and displays row which has value that i selected in list boxes.
This part i completed,
Now what i want is, If i selected "All" in any Listbox, then i don't want to put condition, because "ALL" means it will show all data for that listbox. I have attached my excel file for reference.
What i am doing is, If i selected a item in all listbox, macro is checking next sheet, and displays row which has value that i selected in list boxes.
This part i completed,
Now what i want is, If i selected "All" in any Listbox, then i don't want to put condition, because "ALL" means it will show all data for that listbox. I have attached my excel file for reference.
Code:
Dim ary, ary1, ary2, ary3, ary4
'// Initially size our array with a zer base, then slip it up one upon the first //
'// val being assigned to an element. //
ReDim ary(0 To 0)
ReDim ary1(0 To 0)
ReDim ary2(0 To 0)
ReDim ary3(0 To 0)
ReDim ary4(0 To 0)
For i = 0 To ListBox1.ListCount - 1
For i1 = 0 To ListBox2.ListCount - 1
For i2 = 0 To ListBox3.ListCount - 1
For i3 = 0 To ListBox4.ListCount - 1
For i4 = 0 To ListBox5.ListCount - 1
If ListBox1.Selected(i) Then
'// resize our array ea time we find a val to add. //
ReDim Preserve ary(1 To UBound(ary) + 1)
ary(UBound(ary)) = ListBox1.List(i)
If ListBox2.Selected(i1) Then
ReDim Preserve ary1(1 To UBound(ary1) + 1)
ary1(UBound(ary1)) = ListBox2.List(i1)
If ListBox3.Selected(i2) Then
ReDim Preserve ary2(1 To UBound(ary2) + 1)
ary2(UBound(ary2)) = ListBox3.List(i2)
If ListBox4.Selected(i3) Then
ReDim Preserve ary3(1 To UBound(ary3) + 1)
ary3(UBound(ary3)) = ListBox4.List(i3)
If ListBox5.Selected(i4) Then
ReDim Preserve ary4(1 To UBound(ary4) + 1)
ary4(UBound(ary4)) = ListBox5.List(i4)
Dim e
Set i10 = Sheets("Data")
Set e = Sheets("Home")
Dim d
Dim j
d = 10
j = 2
Do Until IsEmpty(i10.Range("A" & j))
If i10.Range("A" & j) = ary(UBound(ary)) And i10.Range("B" & j) = ary1(UBound(ary1)) And i10.Range("G" & j) = ary2(UBound(ary2)) And i10.Range("C" & j) = ary3(UBound(ary3)) And i10.Range("E" & j) = ary4(UBound(ary4)) Then
'
d = d + 1
e.Rows(d).Value = i10.Rows(j).Value
End If
j = j + 1
Loop
End If
End If
End If
End If
End If
Next
Next
Next
Next
Next