Excel LookUp problems

Excel LookUp problems

Anonymous
Not applicable
663 Views
2 Replies
Message 1 of 3

Excel LookUp problems

Anonymous
Not applicable

Hello ALL! I need your help guys!!!!

 

Please see script below and attached spreadsheet. If parameter DisBeamOffset doesn`t match any of numbers from spreadsheet,  inventor gives me an error:

 

Excel cell not found (bad cell address?): "B-1"

 

NUM=GoExcel.CellValue("B" & CStr(GoExcel.FindRow("c:\Work12\Designs\ILOGIC\iDropOverFrame\drop over common parts.xls", "Sheet1", "DISCHARGE", "=", DisBeamOffset)))
  
FILENAME="c:\Work12\Designs\PARTS\PARTS - T\T37000-T37999\" & NUM & ".ipt"
   
Component.Replace("Sheet1", FILENAME, True)

Component.Replace("Sheet2", FILENAME, True)

How to handle this? Is there any chance to change script and catch the error?

 

Thanks much!

 

 

0 Likes
Accepted solutions (1)
664 Views
2 Replies
Replies (2)
Message 2 of 3

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

If parameter DisBeamOffset doesn`t match any of numbers from spreadsheet, iLogic function GoExcel.FindRow returns -1. 

Sample code below use this fact to handle this situation.

 

'LookUp value
DisBeamOffset = 43  'this value doesn’t exists

Row = GoExcel.FindRow("drop over common parts.xls", _
    "Sheet1", "DISCHARGE", "=", DisBeamOffset)
MsgBox(Row)

If Row >=1  Then
NUM = GoExcel.CellValue("B" & CStr(Row))
    MsgBox(NUM)
Else
    MsgBox("DisBeamOffset = " & DisBeamOffset & _
 "  was not found in Excel sheet")
End If

 

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 3

Anonymous
Not applicable

Thanks man! Spasibo!

0 Likes