Hey guys!
I created a script for running an excel file, but I want it to end by itself when it gets to a blank cell. Here is what I am trying to do but it won't work. Please help!
Rate :=
Clipboard :=
Sleep, 500
Send, {Control Down}{c}{Control Up}
Sleep, 700
If Clipboard =
{
Goto, END
}
End:
ExitApp
Return
End an excel sheet
Re: End an excel sheet
Instead of using classic send keys, use Excel COM instead, here https://autohotkey.com/board/topic/69033-basic-ahk-l-com-tutorial-for-excel/
Re: End an excel sheet
Hello Fenchai!
I am using an already created excel sheet, I just want to come to the last cell and make the script stop running.
I am using an already created excel sheet, I just want to come to the last cell and make the script stop running.
- flyingDman
- Posts: 2817
- Joined: 29 Sep 2013, 19:01
Re: End an excel sheet
I agree with @Fenchai . Whether you are creating a new spreadsheet or working on an existing one, COM is a significantly better way to go compared to simulated keystrokes.
Here is some code to determine whether the active cell is the cell before the first empty cell in the column or whether the active cell is the last non-empty cell in column (two different things...). I assume you are working top down in column C (rather than left to right).
Here is some code to determine whether the active cell is the cell before the first empty cell in the column or whether the active cell is the last non-empty cell in column (two different things...). I assume you are working top down in column C (rather than left to right).
Code: Select all
Xl := ComObjActive("Excel.Application") ;creates a handle to your Application object
#\::
msgbox % xl.Range("C" xl.Rows.Count).End(-4162).address
if (xl.activecell.address = xl.Range("C" xl.Rows.Count).End(-4162).address) ;last non-empty cell in col C
msgbox End
return
#]::
msgbox % xl.range("C1").end(-4121).address
if (xl.activecell.address = xl.range("C1").end(-4121).address) ;cell just above the first empty cell in col C
msgbox End
return
14.3 & 1.3.7