You can try an AppActivate statement just before the SendKeys, e.g:
AppActivate "Microsoft Excel"
SendKeys "{END}"
etc...

But this is still not reliable in a multitasking environment since other
apps may steal focus even after the AppActivate and then the SendKeys goes to
the wrong app (the one with focus at the time the statement is called). I
have big headaches with my email notifications coming up and stealing focus,
so I have learned to avoid SendKeys.

Please note (if you were not aware) that your code could all be done with no
SendKeys:
ActiveCell. "%(=)" 'inputs an AutoSum (Alt-equals
With ActiveCell
Set SumRange = Range(.Cells(0,1),.Cells(0,1).End(xlUp))
.Formula = "=SUM(" & SumRange.Address & ")"
.Offset(-1, 1).Copy
.Offset(1, 0).Range("A1").PasteSpecial xlPasteAll
End With
SumRange.Cells(0,1).Select ' equivalent to your {END}{UP}{UP} due to def'n
of SumRange
--
- K Dales


"Helmut Weber" wrote:

> Hi,
>
> sendkeys is notoriously unreliable anway.
>
> It sends keystrokes to the active window.
>
> And when you are in the VBA editor,
> the keystrokes are sent to the editor window,
> as this is the active window.
>
> Helmut Weber
>
>
>