JerryKing
Mechanical
- Jun 12, 2007
- 4
What’s wrong with the VLookup function my following VBscript codes? The error remind me “type mismatch”.
function searchTimeById(OpId)
Dim objExcel, excelPath, strData,
Set objExcel = CreateObject("Excel.Application")
excelPath = "Z:\OpLibrary.xls"
objExcel.Workbooks.open excelPath, false, true
Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets("Operations")
set RNG = currentWorkSheet.Range("A1:A40")
searchTimeById = currentWorkSheet.Application.VLookup(OpId, RNG, 3, FALSE)
objExcel.Workbooks.Close
objExcel.Quit
Set currentWorkSheet = Nothing
Set objExcel = Nothing
end function
sub main()
Time = searchTimeById(2088)
end sub
The excel sheet (Operations):
OpId Name Time
2088 locate 0.2
2010 drill 0.1
2050 sealing 0.05
function searchTimeById(OpId)
Dim objExcel, excelPath, strData,
Set objExcel = CreateObject("Excel.Application")
excelPath = "Z:\OpLibrary.xls"
objExcel.Workbooks.open excelPath, false, true
Set currentWorkSheet = objExcel.ActiveWorkbook.Worksheets("Operations")
set RNG = currentWorkSheet.Range("A1:A40")
searchTimeById = currentWorkSheet.Application.VLookup(OpId, RNG, 3, FALSE)
objExcel.Workbooks.Close
objExcel.Quit
Set currentWorkSheet = Nothing
Set objExcel = Nothing
end function
sub main()
Time = searchTimeById(2088)
end sub
The excel sheet (Operations):
OpId Name Time
2088 locate 0.2
2010 drill 0.1
2050 sealing 0.05