C
ctm
Private Sub ListBox3_AfterUpdate()
Application.ScreenUpdating = False
ListBox7.Clear
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("InspectionData").Cells(Rows.Count,
"A").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 2 To LastCell
If .Cells(myrow, 1) <> "" Then
If .Cells(myrow, 1).Offset(-1, 2).Value = ListBox5.Value And
_
.Cells(myrow, 1).Offset(-1, 6).Value = ListBox6.Value
Then
For i = 2 To 22
If .Cells(myrow, 1).Offset(i, 2).Value =
ListBox3.Value Then
TextBox4.Value = .Cells(myrow, 1).Offset(i, 2).Value
End If
Next i
End If
End If
Next
End With
Sheets("Main").Activate
Application.ScreenUpdating = True
End Sub
I am trying to capture a value in Column A with the above code.
I have a form which uses a couple of listboxes and a textbox to narrow down
a selected value in a worksheet.
There is ALWAYS a value in column A, and between 2 - 22 rows below that
value in column A, i have numerical values in colum C.
Thus the (For i = 2-22 statement above).
Listbox5 selection is a customers name, that is ALWAYS offset 1 row above
AND Always in Column C(i,2) from the value in column A.
Listbox6 selection is a product. It is ALWAYS offset 1 row Above AND Always
in Column G(i,6) from the value in Column A.
Listbox3 is a numerical value that is ALWAYS in Column C and is between 2
AND 22 rows below a value in Column A.
As the possibility is that there could be MORE than one numerical value the
same in Column C, i have the IF statements with Listbox5 and Listbox6, to
ensure those listbox values are found in cells Offset to the value in Column
A.
*************************************************************************************************
I cannot seem to be able to obtain the Column A value that is OFFSET to the
value selected in Listbox3, and place it in Textbox4.
*************************************************************************************************
Can anyone see the problem in my code, and help me solve this headache of
mine?
Regards
Corey
Application.ScreenUpdating = False
ListBox7.Clear
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("InspectionData").Cells(Rows.Count,
"A").End(xlUp).Row
With ActiveWorkbook.Worksheets("InspectionData")
For myrow = 2 To LastCell
If .Cells(myrow, 1) <> "" Then
If .Cells(myrow, 1).Offset(-1, 2).Value = ListBox5.Value And
_
.Cells(myrow, 1).Offset(-1, 6).Value = ListBox6.Value
Then
For i = 2 To 22
If .Cells(myrow, 1).Offset(i, 2).Value =
ListBox3.Value Then
TextBox4.Value = .Cells(myrow, 1).Offset(i, 2).Value
End If
Next i
End If
End If
Next
End With
Sheets("Main").Activate
Application.ScreenUpdating = True
End Sub
I am trying to capture a value in Column A with the above code.
I have a form which uses a couple of listboxes and a textbox to narrow down
a selected value in a worksheet.
There is ALWAYS a value in column A, and between 2 - 22 rows below that
value in column A, i have numerical values in colum C.
Thus the (For i = 2-22 statement above).
Listbox5 selection is a customers name, that is ALWAYS offset 1 row above
AND Always in Column C(i,2) from the value in column A.
Listbox6 selection is a product. It is ALWAYS offset 1 row Above AND Always
in Column G(i,6) from the value in Column A.
Listbox3 is a numerical value that is ALWAYS in Column C and is between 2
AND 22 rows below a value in Column A.
As the possibility is that there could be MORE than one numerical value the
same in Column C, i have the IF statements with Listbox5 and Listbox6, to
ensure those listbox values are found in cells Offset to the value in Column
A.
*************************************************************************************************
I cannot seem to be able to obtain the Column A value that is OFFSET to the
value selected in Listbox3, and place it in Textbox4.
*************************************************************************************************
Can anyone see the problem in my code, and help me solve this headache of
mine?
Regards
Corey