0

I am copying and pasting some data from ms excel sheet to some other program using the following autohotkey script:

f1::
loop 2000
{
Send, {CTRLDOWN}c{CTRLUP}
sleep 100
send {ALTDOWN}{TAB}{ALTUP}
sleep 100
Send, {CTRLDOWN}v{CTRLUP}{enter}
sleep 100
send {ALTDOWN}{TAB}{ALTUP}
sleep 100
send {down}
}
return

There are more than 2000 entries in column a of an excel sheet which I have to copy and paste into some other program.

My problem is this that all those entries are in random cells i.e. there are so many cells blank in column a in excel sheet.

Is there any command in autohotkey to copy only those cells in which there is data and blank cells can be omitted?

Is it possible to delete all those rows (cells) which are blank in the excel sheet?

This a great solution of the problem suggested by SIDOLA

One more thing I wish to ask is that- If the same problem is occurring while pasting then what should I do, namely I copied some data from excel sheet and if the same data already exist in the program where I wish to paste it then I want that it should escape the pasting of that data and should continue with the next copying. Kindly help..

1
  • Have you tried sorting the data in Excel? This will move the blanks cells to bottom – AEonAX Mar 30 '15 at 7:58
1

You could try checking if the Clipboard variable is empty after sending Send, {CTRLDOWN}c{CTRLUP}. If it is, simply skip the rest of the flow and continue with the next row.

f1::
    loop 2000
    {
        Send, {CTRLDOWN}c{CTRLUP}

        ; If nothing was copied, move down and start over
        if (!Clipboard) {
            Send, {down}
            Continue
        }

        sleep 100
        send {ALTDOWN}{TAB}{ALTUP}
        sleep 100
        Send, {CTRLDOWN}v{CTRLUP}{enter}
        sleep 100
        send {ALTDOWN}{TAB}{ALTUP}
        sleep 100
        send {down}
    }
return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.