开发者

Excel Macro is running using Cut/paste while users switch to email

My users are running Excel Macros, which are using Cut and Paste functions. Now while the macro is running they are switching to email and other apps such as word. Now the question I have always wanted answered is will switching to another app affect what is running in the Excel Macro开发者_StackOverflow中文版 also add in the effect of the Excel macros running in an RDP session and switching in and out of these sessions to see if the macro has finished.


Yes, This can affect how excel works if they are copying and pasting within their application. But there are ways to prevent this. Instead of:

Range("A1:A10").Copy
Sheets("Sheet2").Select
Range("C1").Paste

You can do:

Range("A1:A10").Copy Sheets("Sheet2").Range("C1")

(Putting the destination after the Copy command in the same line)

This will make sure that it will be A1:A10 that gets pasted to C1, so the excel macro shouldn't bomb out, though the user still may find that the when they paste their email from one window to another, that instead they paste A1:A10, if A1:A10 gets copied in between when they hit copy and when they hit paste.

Other ways of doing it are direct values:

sheets("Sheet2").Range("C1").Value = Range("A1")
sheets("Sheet2").Range("C2").Value = Range("A2")

Dan

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜