Page 1 of 1

If,then,else condition

Posted: 02 Feb 2018, 19:19
by hidefguy
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

Re: If,then,else condition

Posted: 02 Feb 2018, 19:49
by Exaskryz
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

Re: If,then,else condition

Posted: 02 Feb 2018, 20:04
by hidefguy
@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.