|
這兩個東西有何關聯咧?單獨用SENDKEYS的時候都不成功,加入DOEVENTS就OK了。
以下代碼運行失敗,sendkeys無作用:
Range("G1").Select
Application.SendKeys "{DOWN}", True
ActiveCell.FormulaR1C1 = "+VLOOKUP(RC[-1],'BOM-LXM'!C[-1]:C[14],16,0)"
Range("f1").Select
Application.SendKeys "^{DOWN}", True
Application.SendKeys "{RIGHT}", True
Application.SendKeys "^+{UP}", True
Application.SendKeys "^{D}", True
Range("H1").Select
Application.SendKeys "{DOWN}", True
ActiveCell.FormulaR1C1 = "+VLOOKUP(RC[-1],'BOM-LXM'!C[-1]:C[14],16,0)"
Range("f1").Select
Application.SendKeys "^{DOWN}", True
Application.SendKeys "{RIGHT 2}", True
Application.SendKeys "^+{UP}", True
Application.SendKeys "^{D}", True
以下代碼運行成功,sendkeys有效:
Range("G1").Select
Application.SendKeys "{DOWN}", True
DoEvents
ActiveCell.FormulaR1C1 = "+VLOOKUP(RC[-1],'BOM-LXM'!C[-1]:C[14],16,0)"
Range("f1").Select
Application.SendKeys "^{DOWN}", True
DoEvents
Application.SendKeys "{RIGHT}", True
DoEvents
Application.SendKeys "^+{UP}", True
DoEvents
Application.SendKeys "^d", True
DoEvents
Range("H1").Select
Application.SendKeys "{DOWN}", True
DoEvents
ActiveCell.FormulaR1C1 = "+VLOOKUP(RC[-1],'BOM-LXM'!C[-1]:C[14],16,0)"
Range("f1").Select
Application.SendKeys "^{DOWN}", True
DoEvents
Application.SendKeys "{RIGHT 2}", True
DoEvents
Application.SendKeys "^+{UP}", True
DoEvents
Application.SendKeys "^d", True
DoEvents
只是這樣的代碼看起來太冗余了,請問要如何修正?謝謝。 |
|