I am using 2 textboxes, 1 listbox, 1 button. I simply want to show a list that contain what is entered in the textboxes.
textbox1 = color
textbox2 = shape
<tbody>
</tbody>
What I have:
What works:
If textbox1.value <> "" and textbox2.value = "" then
set rng = .range("B1:B9")
set fnd = rng.Find(textbox1.value)
Listbox1.clear
if fnd is nothing then ListBox1.AddItem "Result Not Found": Exit Sub
Set first = fnd
With Listbox1
Listbox1.clear
Listbox1.AddItem fnd.Offset(, -1)
Do
Set fnd = rng.FindNext(fnd)
If fnd.Address = First.Address then Exit Do
ListBox1.AddItem fnd.Offset(,-1)
Loop
End With
What doesn't work
Elseif textbox1.value <> "" and textbox2.value <> "" then
set rng.Range("A1:C9")
ctr1 = 1
For i = 1 To 9
If StrComp(textbox1.value, rng(i, 2)) <> 0 then
arr1(ctr1) = i
ctr1 = ctr1 + 1
End If
Next i
ctr2 = 1
For j = 1 To Len(arr1)
If StrComp(textbox2.value, rng(arr1(j), 3)) = 0 then
arr2(ctr2) = arr1(j)
output(ctr2, 1) = rng(arr1(j), 3)
ctr2 = ctr2 + 1
End if
Next j
Listbox1.clear
Listbox1.List = output
End if
What I want:
textbox1.value = red textbox1.value = red
textbox2.value = "" textbox2.value = triangle
<tbody>
</tbody>
<tbody>
</tbody>
Elseif
<tbody>
</tbody>
Elseif
<tbody>
</tbody>
textbox1 = color
textbox2 = shape
TEXTBOX 1 | TEXTBOX 2 | ||
A | B | C | |
1 | BLUE-CIRCLE | BLUE | CIRCLE |
2 | GREEN-TRIANGLE | GREEN | TRIANGLE |
3 | RED-TRIANGLE | RED | TRIANGLE |
4 | RED-SQUARE | RED | SQUARE |
5 | BLUE-SQUARE | BLUE | SQUARE |
6 | RED-TRIANGLE | RED | TRIANGLE |
7 | GREEN-CIRCLE | GREEN | CIRCLE |
8 | GREEN-SQUARE | GREEN | SQUARE |
9 | GREEN-SQUARE | GREEN | SQUARE |
<tbody>
</tbody>
What I have:
What works:
If textbox1.value <> "" and textbox2.value = "" then
set rng = .range("B1:B9")
set fnd = rng.Find(textbox1.value)
Listbox1.clear
if fnd is nothing then ListBox1.AddItem "Result Not Found": Exit Sub
Set first = fnd
With Listbox1
Listbox1.clear
Listbox1.AddItem fnd.Offset(, -1)
Do
Set fnd = rng.FindNext(fnd)
If fnd.Address = First.Address then Exit Do
ListBox1.AddItem fnd.Offset(,-1)
Loop
End With
What doesn't work
Elseif textbox1.value <> "" and textbox2.value <> "" then
set rng.Range("A1:C9")
ctr1 = 1
For i = 1 To 9
If StrComp(textbox1.value, rng(i, 2)) <> 0 then
arr1(ctr1) = i
ctr1 = ctr1 + 1
End If
Next i
ctr2 = 1
For j = 1 To Len(arr1)
If StrComp(textbox2.value, rng(arr1(j), 3)) = 0 then
arr2(ctr2) = arr1(j)
output(ctr2, 1) = rng(arr1(j), 3)
ctr2 = ctr2 + 1
End if
Next j
Listbox1.clear
Listbox1.List = output
End if
What I want:
textbox1.value = red textbox1.value = red
textbox2.value = "" textbox2.value = triangle
A | B | C | |
3 | RED-TRIANGLE | RED | TRIANGLE |
4 | RED-SQUARE | RED | SQUARE |
6 | RED-TRIANGLE | RED | TRIANGLE |
<tbody>
</tbody>
A | B | C | |
3 | RED-TRIANGLE | RED | TRIANGLE |
6 | RED-TRIANGLE | RED | TRIANGLE |
<tbody>
</tbody>
Elseif
Listbox1 |
Red-Triangle Red-Square Red-Triangle |
<tbody>
</tbody>
Elseif
Listbox1 |
Red-Triangle Red-Triangle |
<tbody>
</tbody>