Add the same bit of text to multiple cells taken from Excel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cws
Posts: 27
Joined: 02 Oct 2017, 18:11

Add the same bit of text to multiple cells taken from Excel

20 Apr 2021, 22:54

I will have multiple rows of some string of text, might be email addresses or part numbers.

I want to be able to add text around the values in those cells and store all the new text in the clipboard (for pasting into SQL).

Below would be the rows of data from Excel:
PN1
PN2
PN3
PN4

Copy those cells to the clipboard, run script, and output:
or PN like 'PN1'
or PN like 'PN2'
or PN like 'PN3'
or PN like 'PN4'
User avatar
mikeyww
Posts: 26877
Joined: 09 Sep 2014, 18:38

Re: Add the same bit of text to multiple cells taken from Excel

21 Apr 2021, 05:29

Code: Select all

XL := ComObjActive("excel.application"), str := ""
For c in XL.Selection ; Loop through selected cells
 str .= (A_Index = 1 ? "" : "`n") "or PN like '" c.text "'"
MsgBox, 64, Result, %str%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Joey5, Nerafius, RandomBoy and 154 guests