Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Excel array copy paste loop
#1
Hello, I have been messing around with QM for a bit and after my work saw some of the things it can do was able to convince them to purchase a license. Since then I've been working on improving my macros. What I have now requires a ton of 'Cc and 'Cv with window switching all over the place.

To the question, what would code this code look like? Toss a column of data in excel into an array. Upon a trigger key the first cell in the array will paste into a field that I have selected. Then I select another field and upon the same trigger key press the next cell will paste. This would continue until the end of the array has been reached.

Thank you for your time!
#2
Macro Macro3204
Code:
Copy      Help
ExcelSheet es.Init
ARRAY(str) a
es.CellsToArray(a "sel") ;;get the selected cells. Or you can use a column/row/range definition; see examples.
int row
for row 0 a.len
,str s=a[0 row]
,OnScreenDisplay F"Row {row+1}. Press Down to paste."
,wait 0 KF D
,OsdHide
,key H SE ;;if field text not empty, select it to replace
,paste s
OnScreenDisplay "Done"


#ret
area for testing
#3
Holy cow, this is gorgeous. I can't believe you can do so much with so little code. Thank you so much!


Forum Jump:


Users browsing this thread: 2 Guest(s)