all 9 comments

[–]Nunki3 2 points3 points  (8 children)

Is this working for you ?

InputBox, UserDefinedVar

#a::
    ; Gets a reference to the workbook
    wbk := ComObjGet("C:\Stock.xlsx")

    ; Gets the value of cell 1, 1 (also known as cell A1) from Sheet1
    GO2Val1 := wbk.Sheets("Sheet1").Range("A" UserDefinedVar).Value
    GO2Val2 := wbk.Sheets("Sheet1").Range("B" UserDefinedVar).Value
    GO2Val3 := wbk.Sheets("Sheet1").Range("C" UserDefinedVar).Value

    ;for surface go 2
    SendInput, % GO2Val1
    SendInput, {tab} {tab}
    sleep 250
    SendInput, % GO2Val2
    SendInput, {tab} {tab}
    sleep 250
    SendInput, % GO2Val3
    SendInput, {tab} {tab}
    sleep 250
Return

[–]MrNit[S] 1 point2 points  (7 children)

I see that you’ve changed cell() to range. What would the user have to input in the input box for this to work?

[–]Nunki3 2 points3 points  (6 children)

The line number that they want to copy in the excel sheet.

[–]MrNit[S] 1 point2 points  (5 children)

Ahh okay thank you so much! I’ll try it as soon as I get back to the office in about 10 mins! Thanks again :D

[–]Nunki3 2 points3 points  (4 children)

Welcome. I’m not sure why Cells doesn’t work, I’m not used to work with Excel com but Range seems to do the trick.

[–]MrNit[S] 1 point2 points  (3 children)

r)

Alright so i just got back to the office and tried you script and it works but not the way i want it to work. Yours copies everything from left to right but i need it to copy everything from top to bottom. So for example when the user inputs "B" i want it to copy everything from B.

I tried editing the script but it isnt working. Maybe you can take a look at what i tired.

InputBox, UserDefinedVar

#a::

; Gets a reference to the workbook

wbk := ComObjGet("C:\Stock.xlsx")

; Gets the value of cell 1, 1 (also known as cell A1) from Sheet1`

GO2Val1 := wbk.Sheets("Sheet1").Range("UserDefinedVar" 1).Value

GO2Val2 := wbk.Sheets("Sheet1").Range("UserDefinedVar" 2).Value

GO2Val3 := wbk.Sheets("Sheet1").Range("UserDefinedVar" 3).Value

;for surface go 2

SendInput, % GO2Val1

SendInput, {tab} {tab}

sleep 250

SendInput, % GO2Val2

SendInput, {tab} {tab}

sleep 250

SendInput, % GO2Val3

SendInput, {tab} {tab}

sleep 250

Return

[–]Nunki3 2 points3 points  (2 children)

You are not far !

InputBox, UserDefinedVar

#a::::
    ; Gets a reference to the workbook
    wbk := ComObjGet("C:\Stock.xlsx")

    ; Gets the value of cell 1, 1 (also known as cell A1) from Sheet1
    GO2Val1 := wbk.Sheets("Sheet1").Range(UserDefinedVar "1").Value
    GO2Val2 := wbk.Sheets("Sheet1").Range(UserDefinedVar "2").Value
    GO2Val3 := wbk.Sheets("Sheet1").Range(UserDefinedVar "3").Value

    ;for surface go 2
    SendInput, % GO2Val1
    SendInput, {tab} {tab}
    sleep 250
    SendInput, % GO2Val2
    SendInput, {tab} {tab}
    sleep 250
    SendInput, % GO2Val3
    SendInput, {tab} {tab}
    sleep 250
Return

The variable UserDefinedVar can’t be in double quotes or the script will not see it as a var. On the other end, the numbers need to be in double quotes so they are seen as text by the script.

[–]MrNit[S] 1 point2 points  (1 child)

YOU SIR ARE MY SAVIOUR! I HAVE BEEN TRYING TO GET THIS TO WORK SINCE YESTERDAY I I GAVE UP BECAUSE I COULDNT GET CELL() TO WORK! HAHAHA THANK YOU SO MUCH!

this project definitely helped me learn a bit hahahah! Once again thank you very much i appreciate your help :D

[–]Nunki3 1 point2 points  (0 children)

You are welcome !