I've looked at dozens of solutions to slow VBA/macro copying and pasting, but most of the problems are way beyond what I'm doing, and I just can't get this basic function to work without exponentially slowing down.
I have a "Main" sheet from which I can push any of several buttons to run a macro (that I simply recorded). Each macro should copy another sheet (numbered 1 through 20), and paste it to a sheet called "D", then clear all contents of the numbered sheet. Here's what I have (for copying, for example "2" and pasting to "D", then clearing "2"):
Sub Pull2()
'
' Pull2 Macro
'
'
Sheets("2").Select
Cells.Select
Selection.Copy
Sheets("D").Select
Cells.Select
ActiveSheet.Paste
Sheets("2").Select
Cells.Select
ActiveSheet.ClearContents
Sheets("Main").Select
End Sub
Then I have a button for returning "D" to "2", which is just vice versa of the first macro. This works exactly as I want it, but after pushing the buttons a couple times the loading time gets longer and longer. I've also tried using the CutCopyMode = False function after the macro to try to clear out the clipboard after each execution, but that doesn't help.
Another thing I tried for avoiding the clipboard was:
Sheet4.Range("A1:CZ400").Copy Destination:=Sheet2.Range("A1:CZ400")
Sheet4.Range("A1:CZ400").ClearContents
The same thing happens. The first time I try pulling a numbered sheet to sheet "D", and then returning it, it works great, but after 3 or 4 times it becomes ridiculously slow, or never finishes loading. After each of these copy/pastes if I manually go the "D" or "1" or "2", etc, then the sheet takes a exponentially longer time to load. My guess is there's a better way to do this, so that's why I'm here asking for everyone's assistance.
Bookmarks