Hello,
I am trying to vlookup employees name in a excel file from vb.net, using a variable in the vlookup formula and store the name is another variable. I have tried the below code but it does not seem to work because of the variable in the vlookup formula.
The EmployeeID is always a number which changes depending on the text in the textbox. Can somebody help me please? It seems like the variable "EmployeeID" is not reflecting as a number.
Any help will be appreciated.
Thanks.
I am trying to vlookup employees name in a excel file from vb.net, using a variable in the vlookup formula and store the name is another variable. I have tried the below code but it does not seem to work because of the variable in the vlookup formula.
Code:
xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Open("C:\LookupTable")
xlWorkSheet = xlWorkBook.Worksheets("employee_ID")
Dim EmployeeID = textbox1.text
Dim Name
Name = xlApp.WorksheetFunction.VLookup(" & EmployeeID & ", xlWorkSheet.Range("$A$1:G454"), 7, False)
MsgBox(Name)
The EmployeeID is always a number which changes depending on the text in the textbox. Can somebody help me please? It seems like the variable "EmployeeID" is not reflecting as a number.
Any help will be appreciated.
Thanks.