-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathFind_2.ahk
31 lines (24 loc) · 1.01 KB
/
Find_2.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
; This script is a demonstration of the .Find method. It gets the value of the cell to the right of the active cell.
; Then it will find that value in the range "B:B" on Sheet2.
; Constants
xlValues := -4163
xlWhole := 1
xlApp := ComObjActive("Excel.Application") ; Get a reference to the running instance of Excel.
; Get the value to the right of the active cell. This is the value that we will search for on the other sheet.
cellValue := xlApp.ActiveCell.Offset(0, 1).Value
; Save a reference to "Sheet2". Specify the sheet name (ex: "Sheet2") or number (ex: 2).
MySht := xlApp.ActiveWorkbook.Sheets(2)
FoundCell := MySht.Range("B:B").Find(cellValue,, xlValues, xlWhole)
if (FoundCell)
{
MsgBox, 64, Found, % FoundCell.Address
}
else
{
MsgBox, 64, Not Found, This code does not exist
}
return
; References
; https://autohotkey.com/boards/viewtopic.php?f=5&t=30239
; https://autohotkey.com/boards/viewtopic.php?f=5&t=30577
; Range.Find Method (Excel) - https://msdn.microsoft.com/en-us/library/office/ff839746.aspx