This tutorial explains how to automatically paste selected text in Excel from any program. Here I will mention a AutoHotkey script that you can run on your PC. The script will help you paste selected text in Excel without actually using the Copy/Paste function. You will not have to use the right-click menu of Ctrl+C/Ctrl+V shortcuts. Currently, this app can paste the data in any of the first 3 columns of the Excel file. And there is nothing typical you have to do in order to make it work. You just need AutoHotkey installed on your PC.
If you are saving data in an Excel sheet manually, then you will have to switch between different applications. And you will either have to use the right-click menu options or copy-paste shortcuts again and again. This is irritating and time consuming. This is where the script I have mentioned come in handy. With this, you just have to press a numeric key for selecting text and it will immediately get copied to the top sheet in Excel, And the best part is that, Excel is not required to be running on top.
How to Automatically Paste Selected Text in Excel from any Program?
To get started with this script, you just need to have AutoHotkey application installed. You can download AutoHotkey from here and then install it. This is ~2-3MB in size and after installing it, you have to get the final script. So, just copy the following script and then save it in a file. You can give any name to the script and use “.ahk” as the file extension. You can see that below.
Column := A_ThisHotkey + 0 ; force this to be treated as a number and not a string otherwise Excel will think you are looking for a column named the literal string 1
ClipWait,1 ; wait up to 1 second for text to appear on clipboard
if ErrorLevel ; something went wrong, abort
xlApp := ComObjActive("Excel.Application") ; use open Excel workbook
xlCell_EmptyBelowData := xlApp.Columns(Column).Find("*",,,,,2).Offset(1,0) ; get cell just below last cell with anything in it
if !xlCell_EmptyBelowData.Address ; no cell found with anything in it, column is blank
xlCell_EmptyBelowData := xlApp.Cells(1,Column) ; default to first cell
xlCell_EmptyBelowData.Value := Clipboard
Now, when you have saved the above script, simply execute it. Double click on the file and then it will start running. You can see the icon in the system tray. Start selecting text in web browser, PDFs, and in other applications. After selecting the text, hit any numeric key from 1 to 3. Pressing key 1 will paste the data in first column, key 2 in second column and so on. You can see the working of this script in the GIF that I have added in the beginning of this post.
In this way, you can use this simple AHK script to automatically paste selected text in Excel from any application. Just run the above mentioned script and then keep pasting data in Excel sheet in blink of an eye. You don’t even have to keep the Excel application on top. If you know AHK then you can tweak the above script to work with every column in the Excel file.
If you often work in Excel and do the scraping or data collection work then you will like this script. Just run it and then paste any selected text in an Excel sheet automatically. It will save you a lot of time and if you have some technical skills then you can modify it as well.