Search code examples
excelscriptingexcel-2007autohotkeyvba

AutoHotKey Excel hotstring formulas using arrow keys to find cells for equation


I'm trying to create a couple hotstrings using arrow keys to select cells for the formula that is created.

:*:=concacane::
send =CONCATENATE({right},{right 2},{right 3})
return

The above is the code that I was hoping would work to call the 'CONCATENATE' function and select the three cells to the right of the cell I was typing in. Unfortunately Excel seems to escape the cell I was working in, and I end up with commas and parenthesis spread across a few cells to the right instead of the working formula I was looking for.

I tried using 'sendraw' and adding everything after '=CONCATENATE(' on a second 'send' line hoping that the '=' was some kind of modifier that was messing me up, but that didn't seem to help. I also tried using a key combination instead of a hotstring but I couldn't get that script to do anything at all and a key combination would be less than ideal anyway...

Does anybody have any idea how I can get this to work? Thanks in advance!


Solution

  • I think this will work once you add spaces around the {right} commands.

    :*:cc\:: ; cc\ is shorter for me than =concacane
    Send, =CONCATENATE( {right 1} , {right 2} , {right 3} ) {Enter}
    Return
    

    Tested this in Excel and it works.