C
crimsonkng
In my macro, I need to use the SendKeys command for various reasons. But
it's wierd: sometimes SendKeys works like I programmed them, sometimes just
some of the SendKeys commands work, sometimes Excel "calls" the SendKeys in a
different order than from what I've programmed, and sometimes SendKeys
doesn't work at all. All of the above can happen when
1. I run the macro using a keyboard command or
2. if I run the macro by merely clicking "Run" on the macro list form or
3. if I do an F8 within Visual Basic. (Actually, it seems like SendKeys
never works when I do the F8 thing.)
For example, here's a simple Macro that just won't run consistently/correctly:
SendKeys "%(=)" 'inputs an AutoSum (Alt-equals)
SendKeys "{ENTER}"
ActiveCell.Offset(-1, 1).Range("A1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, -1).Range("A1").Select
SendKeys "{END}"
SendKeys "{UP}"
SendKeys "{UP}"
I can't get a handle on it. Obviously, I'm doing something wrong. Any
hints/suggestions?
Dan
it's wierd: sometimes SendKeys works like I programmed them, sometimes just
some of the SendKeys commands work, sometimes Excel "calls" the SendKeys in a
different order than from what I've programmed, and sometimes SendKeys
doesn't work at all. All of the above can happen when
1. I run the macro using a keyboard command or
2. if I run the macro by merely clicking "Run" on the macro list form or
3. if I do an F8 within Visual Basic. (Actually, it seems like SendKeys
never works when I do the F8 thing.)
For example, here's a simple Macro that just won't run consistently/correctly:
SendKeys "%(=)" 'inputs an AutoSum (Alt-equals)
SendKeys "{ENTER}"
ActiveCell.Offset(-1, 1).Range("A1").Select
Selection.Copy
ActiveCell.Offset(1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, -1).Range("A1").Select
SendKeys "{END}"
SendKeys "{UP}"
SendKeys "{UP}"
I can't get a handle on it. Obviously, I'm doing something wrong. Any
hints/suggestions?
Dan