Jump to content
Sign in to follow this  
JayFran

Excel Help

Recommended Posts

JayFran

Hey guys, I'm a newbie to autoit. I've been working on a script that basically takes the prefix (3 Letters) of our computer names (at work) and matches them against our spreadsheet. Once the search is finished it prints out in the debug window whether or not the computer prefix is in the spreadsheet. Heres what I have so far. Any help is appreciated.

$prefix_open = _ExcelBookOpen("\\phlh72600\new$\New PrefixCodes.xls")
$cprefix = StringRegExp(@ComputerName, "[A-Z] {3} [:alpha:] [:upper:]", 0)
;$array1 = _ExcelReadArray($oExcel, 1, 1, 10, 1) ;Direction is Vertical
$array = _ExcelReadArray($cprefix, 1, 1, 10, 1)

If $cprefix = 1 Then
    _DebugOut("Computer Prefix: " & @ComputerName & " is equal to " $cprefix)
Else
    _DebugOut(@CRLF & "####################################")
    _DebugOut("PREFIX IS INVALID: " & @ComputerName)
    _DebugOut("######################################" & @CRLF)
EndIf
Edited by JayFran

Share this post


Link to post
Share on other sites
FlyinRiz

Hey guys, I'm a newbie to autoit. I've been working on a script that basically takes the prefix (3 Letters) of our computer names (at work) and matches them against our spreadsheet. Once the search is finished it prints out in the debug window whether or not the computer prefix is in the spreadsheet. Heres what I have so far. Any help is appreciated.

$oExcel = _ExcelBookOpen("\\phlh72600\new$\New PrefixCodes.xls")
$cprefix = StringLeft(@computername, 3)
$array = _ExcelReadArray($oExcel, 1, 1, 10, 1)
$result = _ArraySearch($array, $cprefix)
If $result > -1 Then
    _DebugOut("Computer Prefix: " & @ComputerName & " is equal to " $cprefix)
Else
    _DebugOut(@CRLF & "####################################")
    _DebugOut("PREFIX IS INVALID: " & @ComputerName)
    _DebugOut("######################################" & @CRLF)
EndIf

How's that?

-Aaron

Share this post


Link to post
Share on other sites
FlyinRiz

If the code above doesn't make sense, try using in the UDF helpfile and look at the examples.

-Aaron

Share this post


Link to post
Share on other sites
JayFran

Thanks Aaron, this really help out alot. Greatly appreciated.

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×