Link to home
Start Free TrialLog in
Avatar of beatified
beatifiedFlag for United States of America

asked on

AutoHotKey Loop through rows and columns

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
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

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?anchorAnswerId=41824810#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
Avatar of beatified

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Joe Winograd
Joe Winograd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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