Option ExplicitPublic venPicked As Variant
Public cntr3 As Integer
Dim serialNum() As Variant
Private Sub Workbook_Open()
UserForm1.Show
End Sub
'*************************************THIS SUB FINDS THE CELL LOCATION OF THE PART NUMBER PICKED**************************************
Private Sub partNumLB_Click()
'***************THIS IS WHERE I WANT TO FIND THE CELL LOCATION OF THE CLICKED ON VARIABLE*************************
End Sub
'****************************THIS SUB CREATES A LIST OF VENDORS TO CHOOSE FROM*****************************************************
Private Sub whatsAtVenCB_Click()
Dim vendors() As Variant
'get number of populated rows total
Dim data As Range
Dim r As Variant
Dim k As Variant
Set data = Sheet1.Range("i1:i" & Range("i" & Rows.Count).End(xlUp).Row)
cntr3 = 0
For Each r In data
cntr3 = cntr3 + 1
If r.Offset(1) = vbNullString And r.Offset(2) = vbNullString Then
End If
Next r
'resize
ReDim vendors(cntr3)
For k = 1 To cntr3
vendors(k) = Cells(k, 9)
Next
'remove the duplicate PO numbers
Dim outK2 As Integer, inK2 As Integer, newK2 As Integer, Found As Boolean, vendorsNoDup() As Variant
outK2 = 2
newK2 = 2
ReDim vendorsNoDup(1 To UBound(vendors))
vendorsNoDup(1) = vendors(1)
While outK2 <= UBound(vendors)
Found = False
inK2 = 1
Do While inK2 <= UBound(vendors)
If vendors(outK2) = vendorsNoDup(inK2) Then
Found = True
Exit Do
End If
inK2 = inK2 + 1
Loop
If Not Found Then
vendorsNoDup(newK2) = vendors(outK2)
newK2 = newK2 + 1
End If
outK2 = outK2 + 1
Wend
vendorLB.List = vendorsNoDup
End Sub
'***************************THIS SUB WILL POPULATE THE CURRENT PART NUMBERS AT A SPECIFIC VENDOR********************************
Private Sub vendorLB_Click()
Dim prtNumsV() As Variant
Erase prtNumsV
venPicked = vendorLB.Value
arrivedTb.Text = ""
Dim cntrV, t, y, p, venCounter As Integer
'get number of populated rows total
Dim data As Range
Dim r As Variant
Dim k As Variant
Set data = Sheet1.Range("b1:b" & Range("b" & Rows.Count).End(xlUp).Row)
cntrV = 0
For Each r In data
cntrV = cntrV + 1
If r.Offset(1) = vbNullString And r.Offset(2) = vbNullString Then
End If
Next r
'get number of times selected customer appears on sheet
y = 0
venCounter = 0
For t = 2 To cntrV + 2
If venPicked = Cells(t, 9) Then
venCounter = venCounter + 1
End If
Next
On Error Resume Next
'populate partnumber listbox, excluding parts that have alreay arrived back at hexcel
ReDim prtNumsV(venCounter)
ReDim serialNum(venCounter)
t = 0
p = 0
For t = 2 To cntrV + 2
If venPicked = Cells(t, 9) And UCase(Left(Cells(t, 12), 7)) <> "ARRIVED" Then
prtNumsV(p) = Cells(t, 3).Value
serialNum(p) = Cells(t, 6).Value
p = p + 1
End If
Next
If p = 0 Then
arrivedTb.Text = "NO PARTS AT VENDOR"
End If
partNumLB.List = prtNumsV
End Sub