Naveed Posted February 24, 2010 Share Posted February 24, 2010 #include <ExcelCOM_UDF.au3> $file = @ScriptDir & "\resource\Subnets.xlsx" $oExcel = _ExcelBookOpen($file, 0) ; 10.225.211.91 ; 172.17.144.24 $ip1 = "10.225.211.91" $ip2 = StringSplit($ip1, ".") $sFindWhat = $ip2 & "." & $ip2 & "." & $ip2 $sRangeOrRowStart = "A1" $iRowEnd = "500" $StrRow = _ExcelFindInRange($oExcel, $sFindWhat, $sRangeOrRowStart,$iRowEnd) $check = StringLen($StrRow) MsgBox(1,"",$StrRow) If $check < 1 Then MsgBox(1,"","doesnt Exist") Else $check = StringLen($StrRow) MsgBox(1,"",$check) MsgBox(1,"",$StrRow) $result = StringTrimLeft($StrRow, 1) $read = "C" & $result $match = _ExcelReadCell($oExcel, $read, 1) MsgBox(1,"",$match) EndIf _ExcelBookClose($oExcel, 0, 0) I am getting the above error when i am trying to search for an ip address from an excel sheet, the excel sheet has a list of subnets and matching locations. If the ip address exists on the subnets list then it works fine and returns the corresponding location, however when the ip address is not on the list then i get the Error. Can anybody help with either a solution or some sort of error capture to stop the script from crashing. i have tried a simple IF statement but it also errors before the error can be captured. NB - the extra msgbox's are just there to try and capture the error. Any assistance will be much appreciated. Link to comment Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!Register a new account
Already have an account? Sign in here.Sign In Now