It looks like you find each non-empty cell in column A (myrow)
then you look to the previous row (myrow - 1) and see if the cell in column
B is equal to the value in Listbox1 and the cell in column F is equal to the
value in Listbox2
if so, then you loop from myrow + 2 to myrow + 22 and if a cell in column
3 is numeric, does not have a strike through font and is greater than or
equal to the value in the textbox, it is added to listbox3.
for your command button to work, you would have to find that same reference
row (myrow) and work from there. It doesn't do that now - it loops through
all the data in column C - and since you say data values can have duplicates,
it would not restrict itself to the items in Listbox3. I think the easiest
would be to add a hidden column in listbox3 that records what ever
information you want to show in label7 and when the selection is made in
listbox3, just extract that from the list. Or you could use a hidden column
to record the row number of the elements in listbox3.
If you need help with that, then I would probably need you to send me the
workbook.
--
Regards,
Tom Ogilvy
"Corey" wrote:
Not really sure if this will make things easier or more difficult to solve,
but the following code is what populates Listbox3.
It When selected it may be easier to get Label7 to display the Column A value in this code(??) than
by pressing a CommandButton?
I do not know.
Private Sub TextBox1_Change()
Application.ScreenUpdating = False
ListBox3.Clear
If TextBox1.Value < "" Then
Dim lastcell As Long
Dim myrow As Long
Dim i As Long
On Error Resume Next
lastcell = Worksheets("InspectionData").Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 1 To lastcell
If .Cells(myrow, 1) < "" Then
If .Cells(myrow, 1).Offset(-1, 2).Value = ListBox1.Value Then
If .Cells(myrow, 1).Offset(-1, 6).Value = ListBox2.Value Then
For i = 2 To 22
If .Cells(myrow, 3).Offset(i, 0).Font.Strikethrough = False Then
If Cells(myrow, 3).Offset(i, 0).Value < "" Then
If IsNumeric(.Cells(myrow, 3).Offset(i, 0)) Then
If .Cells(myrow, 3).Offset(i, 0).Value < "" And .Cells(myrow, 3).Offset(i, 0).Value =
Val(TextBox1.Value) Then
ListBox3.AddItem Cells(myrow, 3).Offset(i, 0)
ListBox3.List(ListBox3.ListCount - 1, 1) = Cells(myrow, 3).Offset(i, 0).Address
End If
End If
End If
End If
Next i
End If
End If
End If
Next
End With
End If
Label8 = ListBox3.ListCount
Application.ScreenUpdating = True
End Sub
Corey....