Copy & Paste Issues

stapuff

Well-known Member
Joined
Feb 19, 2004
Messages
1,126
I use each one of the pieces of code below in my project. The middle piece is the only one that when pasted shows any formula's in it. Why? It is copying the same range and pasting it to different workbooks. I have stepped through the code several times. I can not for the life of me figure this out.

Any help would be greatly appreciated.

Kurt


Sheets("sheet1").Select
Range("A2:I200").Select
Selection.Copy
Windows("Small.xls").Activate
Range("A2").Select
ActiveSheet.Paste


Sheets("sheet1").Select
Range("A2:I200").Select
Selection.Copy
Windows("Medium.xls").Activate
Range("A2").Select
ActiveSheet.Paste


Sheets("sheet1").Select
Range("A2:I200").Select
Selection.Copy
Windows("Large.xls").Activate
Range("A2").Select
ActiveSheet.Paste
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi Kurt,
I don't see any reason why one would be any different than the others.
Do you want them all to paste formulas, or none of them to?

Try replacing what you're using with one of these.
1 - For all of them to retain any formulas present:
Code:
Sub Test()
Dim Rng As Range
Sheets("Sheet1").Activate
Set Rng = [A2:I200]
Workbooks("Small.xls").Sheets("Sheet1").[A2:I200].Value = Rng.Formula
Workbooks("Medium.xls").Sheets("Sheet1").[A2:I200].Value = Rng.Formula
Workbooks("Large.xls").Sheets("Sheet1").[A2:I200].Value = Rng.Formula
End Sub
Or...
2 - For none of them to retain any formulas:
Code:
Sub Test()
Dim Rng As Range
Sheets("Sheet1").Activate
Set Rng = [A2:I200]
Workbooks("Small.xls").Sheets("Sheet1").[A2:I200].Value = Rng.Value
Workbooks("Medium.xls").Sheets("Sheet1").[A2:I200].Value = Rng.Value
Workbooks("Large.xls").Sheets("Sheet1").[A2:I200].Value = Rng.Value
End Sub
Maybe one or the other will help,
Dan
 
Upvote 0
Dan -

Thanks for the post back. I can't for the life of me understand why 1 is doing it differently either. I will try your 2nd suggestion. I want everything but the formula's.

Thanks again for your post,

Kurt
 
Upvote 0
Dan -

You suggestion worked on getting rid of the formula's but now I lost all of my cell coloring.

In column I - I have cells filled with the color of the cell value. If "Green" cell filled green, If "Blue" then blue filled, etc.

I want the code to copy the range and paste everything except formula's. (Color, font, format, values).

What do I need to do?

Thanks for your help.

Kurt
 
Upvote 0
Ah... I see.
Then maybe it's best to go back to what you had originally, with a bit of a twist.
I'm thinking something along the lines of:
Code:
Sub Test()
Sheets("Sheet1").Select
Range("A2:I200").Copy

Windows("Small.xls").Activate
Range("A2").Select
ActiveSheet.Paste
Selection.Value = Selection.Value

Windows("Medium.xls").Activate
Range("A2").Select
ActiveSheet.Paste
Selection.Value = Selection.Value

Windows("Large.xls").Activate
Range("A2").Select
ActiveSheet.Paste
Selection.Value = Selection.Value

End Sub
This will copy everything, (formats, values, formulas, etc) and then convert the formulas to values after pasting.

Hope it helps,
Dan
 
Upvote 0

Forum statistics

Threads
1,207,422
Messages
6,078,438
Members
446,337
Latest member
nrijkers

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