Jump to content

There must be a better way


Recommended Posts

I know there must be a better way than to add all of the "Or"

#include <excel.au3>

$ExcelWinList = WinList ("Microsoft Excel")
    $Title = StringReplace ($ExcelWinList [1] [0], "Microsoft Excel - ", "")
$oExcel = _ExcelBookAttach ("Microsoft Excel - " & $Title, "Title")
$ActiveCell = $oExcel.Application.ActiveCell.Address
If $ActiveCell = "$A$23" Or $ActiveCell = "$A$39" Or $ActiveCell = "$A$59" Or $ActiveCell = "$A$75" Or $ActiveCell = "$A$91" Or $ActiveCell = "$A$112" Or $ActiveCell = "$A$128" Or $ActiveCell = "$A$144" Or $ActiveCell = "$A$160" Or $ActiveCell = "$A$176" Or $ActiveCell = "$A$192" Then
    MsgBox(0, "Success", "Active Cell = " & $ActiveCell,2)
EndIf
[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!
Link to comment
Share on other sites

You could use a StringRegExp()

Similar question I'll post an example in a few...

Add:

Something like...

If StringRegExp($ActiveCell, "(?i)\$A\$(23|39|59|75|91|112|128|144|160|176|192)") Then
    MsgBox(0, "Success", "Active Cell = " & $ActiveCell,2)
EndIf

Thanks! That is slick!
[topic="21048"]New to AutoIt? Check out AutoIt 1-2-3![/topic] Need to make a GUI? You NEED KODA FormDesigner!
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...