HI,
I have the below code and it keeps erroring out
What I am trying to do is in a userform write an asset ID in the txtpart box, once that comes up it then searches Stock tab for that asset ID in Column A and should then return whatever is in column B for that asset, next text box (.txtloc) field. Problem i have is though it keeps erroring and is saying the Stock.Range Bit is the problem, its says object variable or with block variabvle not defined
Any ideas?
I have the below code and it keeps erroring out
What I am trying to do is in a userform write an asset ID in the txtpart box, once that comes up it then searches Stock tab for that asset ID in Column A and should then return whatever is in column B for that asset, next text box (.txtloc) field. Problem i have is though it keeps erroring and is saying the Stock.Range Bit is the problem, its says object variable or with block variabvle not defined
Any ideas?
VBA Code:
Private Sub Txtpart_AfterUpdate()
If WorksheetFunction.CountIf(Stock.Range("A:A"), Me.txtPart.Value) = 0 Then
MsgBox "Not in Stock"
Me.txtPart.Value = ""
Exit Sub
End If
With Me
.txtLoc = Application.WorksheetFunction.VLookup(CLng(Me.txtPart), Stock.Range("Lookup"), 2, 0)
End With
End Sub