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?