Using Clipboard to compare to data in excel sheet
Using Clipboard to compare to data in excel sheet
Hi,
I would like to know how to use Clipboard to compare to data in Excel spreadsheet.
Thank you
I would like to know how to use Clipboard to compare to data in Excel spreadsheet.
Thank you
Re: Using Clipboard to compare to data in excel sheet
Code: Select all
Clipboard = abc
Sleep, 100
XL := ComObjActive("Excel.Application")
For c In XL.Selection
If (Clipboard = c.Text)
MsgBox, 64, Found it!, % c.Address
Re: Using Clipboard to compare to data in excel sheet
Hi,
And thank you for reply.
Can I put say " Bypass" using Set Clipboard. and have Clipboard search for that in spreadsheet? Or put in Clipboard "Bypass' and have a GOTO Routine?
What i am trying to do is if certain conditions exist in spreadsheet, bypass it, or process it.
I really do appreciate you expertise.
Thank you
And thank you for reply.
Can I put say " Bypass" using Set Clipboard. and have Clipboard search for that in spreadsheet? Or put in Clipboard "Bypass' and have a GOTO Routine?
What i am trying to do is if certain conditions exist in spreadsheet, bypass it, or process it.
I really do appreciate you expertise.
Thank you
Re: Using Clipboard to compare to data in excel sheet
Code: Select all
Clipboard = Bypass
Sleep, 100
; ----------------------------
If xlFindAll(Clipboard)
MsgBox, 64, Success, Found!
Else MsgBox, 48, Failure, Not found.
xlFindAll(needle, rng := "", xl := "") { ; https://www.autohotkey.com/boards/viewtopic.php?p=156838#p156838
; https://www.autohotkey.com/boards/viewtopic.php?p=462637#p462637
(!IsObject(xl)) && xl := ComObjActive("Excel.Application")
(!IsObject(rng)) && rng := rng = "" ? xl.ActiveSheet.UsedRange.Cells : xl.Range(rng)
If !found := rng.Find(needle, rng.Cells(rng.Cells.Count))
Return
result := found, address := found.Address
While (address != (found := rng.FindNext(found)).Address)
result := xl.Union(result, found)
Return result
}
Re: Using Clipboard to compare to data in excel sheet
Hi,
You are very knowledgeable, and thank you. One last question.
Is there a simple way to move a "Process" or "Bypass" statement to a GOTO command from Excel
I appreciate your help, and your knowledge.
Thanks
You are very knowledgeable, and thank you. One last question.
Is there a simple way to move a "Process" or "Bypass" statement to a GOTO command from Excel
I appreciate your help, and your knowledge.
Thanks
Re: Using Clipboard to compare to data in excel sheet
You can use Goto, though Gosub is usually a better choice (if not a function).
Explained: Labels
Explained: Labels
Code: Select all
F3::
If xlFindAll(Clipboard)
Gosub, Found
Else Gosub, NotFound
Return
Found:
MsgBox, 64, Success, Found!
Return
NotFound:
MsgBox, 48, Failure, Not found.
Return
xlFindAll(needle, rng := "", xl := "") { ; https://www.autohotkey.com/boards/viewtopic.php?p=156838#p156838
; https://www.autohotkey.com/boards/viewtopic.php?p=462637#p462637
(!IsObject(xl)) && xl := ComObjActive("Excel.Application")
(!IsObject(rng)) && rng := rng = "" ? xl.ActiveSheet.UsedRange.Cells : xl.Range(rng)
Try found := rng.Find(needle, rng.Cells(rng.Cells.Count))
If !found
Return
result := found, address := found.Address
While (address != (found := rng.FindNext(found)).Address)
result := xl.Union(result, found)
Return result
}
- flyingDman
- Posts: 2822
- Joined: 29 Sep 2013, 19:01
Re: Using Clipboard to compare to data in excel sheet
While XlFindAll() is a very clever function, it is particularly good at returning an array of the found cells. If the purpose here is just to find out if a certain string exists in the spreadsheet (and if so do something), the following is all you need:
Note that the 4th parameter of Find() is 1: "Match against the whole of the search text" or 2: "Match against any part of the search text".
Code: Select all
Clipboard = x
gosub, % ComObjActive("excel.application").activesheet.usedrange.Find(Clipboard,,,2) ? "go" : "nogo"
return
go:
msgbox Found
return
nogo:
msgbox Not Found
return
14.3 & 1.3.7
Re: Using Clipboard to compare to data in excel sheet
Hi,
I am very new at this, and wonder how do I enter this code into Macro?
I do appreciate the help.
thank you
I am very new at this, and wonder how do I enter this code into Macro?
I do appreciate the help.
thank you
- flyingDman
- Posts: 2822
- Joined: 29 Sep 2013, 19:01
Re: Using Clipboard to compare to data in excel sheet
It might make sense to have a look here: https://www.autohotkey.com/docs/AutoHotkey.htm (as a starting point).
Note: Autohotkey is a programming language. It is probably much more accessible than higher end languages, but it will still be a steep learning curve for most. If you intend to wing it, without documentation, you will not get very far. Relying only on the forum, is also probably not a good idea.
Note: Autohotkey is a programming language. It is probably much more accessible than higher end languages, but it will still be a steep learning curve for most. If you intend to wing it, without documentation, you will not get very far. Relying only on the forum, is also probably not a good idea.
14.3 & 1.3.7
Re: Using Clipboard to compare to data in excel sheet
Hi,
And thank you for Link. I am just trying to get extra credit project done, before end of semester. Will try to get it done using the link.
Thanks again
And thank you for Link. I am just trying to get extra credit project done, before end of semester. Will try to get it done using the link.
Thanks again
Re: Using Clipboard to compare to data in excel sheet
Please have Prof mark "A" in our records. Thanks.