sendkeys string

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I assigned a shortcut key to a macro using "ctrl" and a letter. The
following "sendkeys string:=" does not function properly. If I run the
macro without the shortcut key, the macro runs properly. Is there a remedy
so that the macro may run using the shortcut key? The macro line is as
follows:

Sub lop()
For count = 1 To 3
SendKeys String:="={left}-4~{down}"
Next count
End Sub

Spreadsheet example:

21 active cell (macro is run from the active cell)
24
33
 
I assigned a shortcut key to a macro using "ctrl" and a letter. The
following "sendkeys string:=" does not function properly. If I run the
macro without the shortcut key, the macro runs properly. Is there a remedy
so that the macro may run using the shortcut key? The macro line is as
follows:

Sub lop()
For count = 1 To 3
SendKeys String:="={left}-4~{down}"
Next count
End Sub

Spreadsheet example:

21 active cell (macro is run from the active cell)
24
33

Hello Hawki,

If you want to move 4 cells to left and then down, try this...

Sub Lop()
For count = 1 To 3
SendKeys "{Left 4}"
SendKeys "{Down}"
Next count
End Sub

Sincerely,
Leith Ross
 
Thanks for your assistance.

My objective is to enter formulas in a column that have numbers in adjacent
cells in an adjacent column by entering an "=" sign, move to the "left" to
enter and address of the adjacent cell in an adjacent column, enter a "-"
sign, enter a "4", press the "enter" key, move "down" one cell in the same
column, repeat the action another 2 times.
 
Any reason you can't just use the normal Excel object/methods ?
Only use SendKeys when you have no other option.

Activecell.Formula="=" & Activecell.offset(1.0).value & "-4"

Add your loop

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top