If,then,else condition

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hidefguy
Posts: 57
Joined: 11 Apr 2017, 20:42

If,then,else condition

02 Feb 2018, 19:19

I’m trying to integrate this logic into my AHK project, but it doesn’t seem to work. I might be missing something simple.

InputBox, @, Starting row number

XXX.Range("G”@).copy
YYY.Range(“A1”).paste

If @>1 then
XXX.Range("G”@).copy
YYY.Range(“A2”).paste
Else
If @>2 then
XXX.Range("G”@).copy
YYY.Range(“A3”).paste
ExitApp
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: If,then,else condition

02 Feb 2018, 19:49

You'll need COM to establish the XXX and YYY (Excel guides/references for AHK have been published, you can search for those in Tutorials section), and this looks like VBA. But something to this effect would work in AHK:

Code: Select all

If (@>1) ; if @ is allowed as a variable name, never tried it, guess it could be
{
XXX.Range("G"@).copy ; may try .Range.("G" . @) where . is the concatenation operator
YYY.Range("A2").paste
}
else if (@>2)
{
XXX.Range("G"@).copy
YYY.Range("A3").paste
}
ExitApp
hidefguy
Posts: 57
Joined: 11 Apr 2017, 20:42

Re: If,then,else condition

02 Feb 2018, 20:04

@Exaskryz

I posted a simplified variation of the target snippet, but yes, it does utilize COM scripting. And thank you very much for the sample code. Looks like it fits the bill.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 257 guests