View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Use number in text box to look up value in a workbook sheet

Hi all,

I would like to use the number that it typed into the textbox
"txt_PrtNumber" and then do a Vlookup in the sheet "Local Parts" to find the
part description in column 2 of that sheet.
Could i have some help please, i have used some code from Dave Pieterson But
keep getting an error.

Any help would be much appreciated...


myPartNum = Me.txt_PrtNumber.Value

If vmyComma = 0 Then
Set LookupRange =
Workbooks("Logistics_Cost_TM_Input.xls").Worksheet s("Local
Parts").Range("A2:B65536")

If myPartNum < "" Then
res = Application.VLookup(myPartNum, LookupRange, 2, 0)
If IsError(res) Then
res = Application.VLookup(CDbl(myPartNum), _

Workbooks("Logistics_Cost_TM_Input.xls").Worksheet s("Local
Parts").Range(LookupRange), 2, False)

Me.Chk_NoPrtNo.Enabled = False
Me.txt_PrtDescription.Value = "The part Derscription will be
inserted in the request"
Me.txt_PrtDescription.Enabled = False
Else
MsgBox "Description not found, please enter", vbOKOnly +
vbCritical, "ERROR - Description not found"
Me.txt_PrtDescription.Enabled = True
Me.txt_PrtDescription.Text = vbNullString
Me.Chk_NoPrtNo.Enabled = False
Exit Sub
End If
End If
Else
Me.Chk_NoPrtNo.Enabled = False
Me.txt_PrtDescription.Value = "The part Derscriptions will be
inserted in the request"
Me.txt_PrtDescription.Enabled = False
End If


--
Les