How to copy the data and search it by ctrl + f in excel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 06:56

How can I create a script to copy the data and search it by ctrl+f in excel ?
I tried this following script. But it doesn't work.

Code: Select all

Appskey & f:: 
Send, {f2}
Send ^a
Send ^c
Send ^f
Send ^v
return


How can i fix the issue?
Thanks for any help in advance.
User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 07:05

Code: Select all

AppsKey::AppsKey
AppsKey & f::
Clipboard =
Send {F2}^a^c
ClipWait, 0
If ErrorLevel {
 MsgBox, 48, Error, An error occurred while waiting for the clipboard. Aborting.
 Return
} Else If !WinExist("ahk_class XLMAIN")
 Return
WinActivate
Send ^f
WinWaitActive, Find and Replace,, 3
Send % ErrorLevel ? "" : "^v"
Return
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 15:48

try:

Code: Select all

#\::											; or the hotkey of your choice
xl := ComObjActive("excel.application")
xl.Cells.Find(xl.activecell.text, xl.activecell).select
return
sending simulated keystrokes to an excel sheet is not a great idea...
14.3 & 1.3.7
User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 16:35

I imagined that the source document was not Excel-- but still agree that the "direct search" method as shown here is better than ^f when possible.
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 17:03

If the source is not Excel, why press F2?
14.3 & 1.3.7
User avatar
mikeyww
Posts: 26859
Joined: 09 Sep 2014, 18:38

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 17:11

I have no idea! I was not really trying to guess; I imagine that you are right. With your guess being likely right, your solution seems much more appropriate!
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 19:16

flyingDman wrote:
21 Sep 2021, 15:48
Thank you for your help.
I prefer excel com way. ^^ But it doesn't work.
Last edited by hancre on 21 Sep 2021, 19:19, edited 1 time in total.
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 19:19

mikeyww wrote:
21 Sep 2021, 16:35
When I write the script and this article, I forget F2 isn't good for excel Com.
There''re several scripts with excel Com libraries.

Thank you for your help.
hancre
Posts: 248
Joined: 02 Jul 2021, 20:51

Re: How to copy the data and search it by ctrl + f in excel

21 Sep 2021, 20:33

mikeyww wrote:
21 Sep 2021, 19:32
My notebook may casuse the problem.
In my notebook, scripts doesn't work sometimes.
But the scripts work well in others' computer.

I'll buy a better notebook later. @.@

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: haomingchen1998, mikeyww, mmflume, roysubs, scriptor2016, ShatterCoder and 102 guests