Why your 10‑line flow fails (but the 3‑line test works)
1) Focus drifts
Even a quick UI event (status bar refresh, tooltip, background dialog, notification) can steal focus for a few milliseconds. In a short test, you usually remain focused; in a longer flow, you often don’t.
2) Edit mode state differs
If the target cell is still in edit mode (e.g., after a prior SendKeys typed = or a previous action left the cell in edit), {Right} will move the caret within the formula text instead of moving the active cell. That produces your symptom: you end up with -BW1496 typed, but the navigation didn’t happen.
3) Excel isn’t ready
After a selection change or a screen update, Excel may need a fraction of a second to repaint or commit. If you type immediately, the first key can be ignored or applied to the wrong place.
4) Race conditions from “SendKeys” emulation
SendKeys simulates keystrokes; it’s best‑effort and not transactional. Small timing differences in a bigger flow change the outcome.
Quick fixes if you must keep SendKeys
If you’re time‑pressed, try this hardened sequence before your existing key string:
1) Ensure the window has focus
Use Focus window (target: your Excel window title).
Then add a tiny Wait 200–300 ms.
2) Exit any edit mode before navigating
Prepend {Esc} to your key sequence to guarantee you’re not editing a cell.
Optional: send {F2}{Esc} (enter edit, then exit) to normalize state.
3) Normalize active cell deterministically
Use Press keys → Ctrl+g (Go To…) then type a safe anchor like A1 and press {Enter}.
From there, use {Right} navigation relative to a known anchor (or better, jump to the exact address you want; see next section).
4) Slow it down just a little—strategically
Instead of a big general delay, add 10–25 ms inter‑key delay only between navigation and text entry boundaries (e.g., after {Right}{Right}, pause 50–100 ms, then type =-BW1496).
5) Break the sequence into atomic steps
SendKeys: {Esc}
SendKeys: ^g → Type A1 → {Enter}
SendKeys: {Right}{Right}
SendKeys: =-BW1496
SendKeys: {Enter}{Up}
This reduces the chance a whole chain goes wrong if a single key is missed.
Naming note: Your current string ={Right:2}-BW1496{Enter}{Up} suggests you’re using PAD’s brace‑syntax to repeat keys. That’s fine, but in longer flows it’s often safer to split into multiple Send keys actions so you can insert micro‑waits between navigation and text entry.
Prefer to use Excel actions, instead of sending keys.
✅ If this answer helped resolve your issue, please mark it as Accepted so it can help others with the same problem.
👍 Feel free to Like the post if you found it useful.