AutoHotKey Loop through rows and columns

beatified
beatified used Ask the Experts™
on
I would like to loop through columns in Excel via AHK script.

XL := ComObjActive("Excel.Application")
Columns := Object(1,"A",2,"B",3,"C",4,"D",5,"E",6,"F",7,"G",8,"H",9,"I",10,"J",11,"K",12,"L",13,"M",14,"N",15,"O",16,"P",17,"Q")
For Keys, Value In Columns
Row := 3
Loop, 10
{
    XL.Range(????? . Row). Value := "Test" A_Index
}

Open in new window


I'm having trouble with the how to call the column and loop to the next column. The goal in the end is to copy cells one at a time and assign a variable to each cell in a row and then loop through that on the following row.

So...
ColumnLoop
B3 Copy to clipboard Paste to Variable appended with A3
C3 Copy to clipboard Paste to Variable appended with A3
through to Column H
RowLoop
Should do the same as above but on Row 4
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
Hi Stuart,

> I would like to loop through columns in Excel via AHK script.

My AutoHotkey code in one of our previous threads does that:
https://www.experts-exchange.com/questions/28973610/AutoHotKey-vs-Pulover's-Macro-Creator-syntax.html#a41824810

Let me know if you're able to leverage that code into what you're looking for this time. If not, I'll take a run at it for you, in which case it would be helpful to have a sample input spreadsheet and the output spreadsheet that you want from it (I don't understand your exact requirements from your post). Btw, as a side comment, I'm sure that the clipboard won't be involved...we'll use variables in the AutoHotkey script, not the clipboard. Regards, Joe

Author

Commented:
And here I go trying to reinvent the wheel that is pretty much exactly what I am trying to do again its just been a while since I could work on it.

Yes the only important factor is to have the data in the variable the clipboard can get messy.
Developer
Fellow 2017
Most Valuable Expert 2018
Commented:
> that is pretty much exactly what I am trying to do again its just been a while since I could work on it

OK, then let me know if you can get it to work for you this time or if you need help revising the AutoHotkey code.

> the clipboard can get messy

Exactly! Your original post at the previous thread used the clipboard, but my revised, "much better" way did not...everything needed is stored in variables in the script. Regards, Joe
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018
Hi Stuart,
I'm trying to clean up open questions at EE...this is one of them. Do you need more help with it? Regards, Joe

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial