excel粘贴时出现故障,在Excel 2013中使用VBA复制和粘贴时出现问题

用户在Excel2013中遇到一个问题,尝试将公式从一个范围复制到另一个范围时,公式意外地粘贴到了另一工作簿中。问题在于`ActiveSheet.Paste`命令不起作用。在另一线程中找到了解决方案,使用`Selection.PasteSpecial xlPasteAll`修复了问题。尽管如此,用户仍想知道为什么`ActiveSheet.Paste`不再有效。
摘要由CSDN通过智能技术生成

I'm attempting to process a large number of large files and need to copy/paste formulas from one range of cells to another. The code I'm using is this:

Range("I12:P12").Select

Selection.Copy

For i = 13 To 3000

ActiveCell.Offset(1, 0).Select

ActiveSheet.Paste

Next

When I run the code, instead of pasting the copied formulas into the destination cells, the program pastes the formulas into the corresponding cells of ANOTHER open workbook. I wrote the code in Excel 2010 and it worked fine. The original code was much simpler.

Rather than the For...Next structure, I was able to select the destination cells using a blanket range statement:

Range("A1:A3000").Select

ActiveSheet.Paste

When I ran it on Excel 2013 it began behaving badly.

I need the other workbook open as it provides inputs to the code that is being executed. There is, however, no code for writing to the other open workbook. The only copy location is the active worksheet in the active workbook.

Any thoughts?

解决方案

Found a solution in another thread that fixed the problem. Using Selection.PasteSpecial xlPasteAll. Still, the original question remains. Why doesn't ActiveSheet.Paste work?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值