Copy Paste Problems

dcoledc

Active Member
Joined
May 6, 2010
Messages
403
Does copying and pasting via VBA mess the sheet up?

I have been running some code that works fine initially but eventually starts to make the SHEET run very slowly. Meaing, if I reopen the book and NOT enable macros the sheet that was running the code moves very slowly.

So, does copy/paste damage the sheet in some way after repeated use? I mean, why would the sheet start running slow even when I am not running code? What is the connection?

I am looking for general understanding regarding this.

Just for information, here is what I am doing:

I have a workbook with 6 sheets in pairs. Meaning one sheet is sort of a defualt and its mate can be altered.


The user can make changes to a sheet and then choose to save or cancel the changes. If they save the changes, the default is then updated to match the changes. If they decide not to save the changes, the changed sheet is then updated to match the default.

I am running the same macro for all sheets, yet for some reason, one sheet keeps getting bogged down.

I am trying to copy/paste with formatting.
Here are the lines of code I am using.

This code updates the default:
Code:
ActiveSheet.Range(OrigRange).Copy Destination:=Sheets(X).Range(OrigRange)
ActiveSheet.Range(Note).Copy Destination:=Sheets(X).Range(Note)

This code restores the altered sheet to the default:

Code:
Sheets(X).Range(OrigRange).Copy Destination:=ActiveSheet.Rang(OrigRange)               
Sheets(X).Range(Note).Copy Destination:=ActiveSheet.Range(Note)

Honestly, I don't konw that this is the cause of my problem or not, but it seemed like a logical place to start. It is a bit challenging to diagnose the problem as it works fine initially and then random seems to bog down.
 
The conditional formatting was the cause of my bloating. I cleared all formatting and problem resolved immediately.

I have tried the pastespecial option but ran into a problem because of merged cells. I can't get arouind the fact that they are merged, so have resorted to creating a series of if/then statements within a sub to replace the conditional formatting on the sheet. This way there is formatting to carry over when pasting.

I don't know if this is the best solution or not. It is a ton of code.

Are you aware of anyway of getting around the merged cells issue when copy/paste?

Thank yet again.:)
 
Upvote 0

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
I think it was VoG who had redirected me here:

http://www.mrexcel.com/forum/showthread.php?t=335123

It's frightening - and quite amazing.
I mean it's really fantastic...

Don't know any way around it though...
Now when I make sheets, I've found it's ok to merge them horizontally, but not vertically for the operations I use, and this seems to keep VBA and copy/paste pretty happy.

At first I thought it was a huge setback on design, but I've gotten pretty comfortable only merging horizontally.
Hope it helps :D
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top