Copy and paste VBA

anguschanch

New Member
Joined
Jun 16, 2014
Messages
45
Hi i wrote this code but it doesnt work as i expected. Can someone please help me solving it?


There are 366 sheets in my workbook, namely "Sheet1", "1", "2",...,"365".
In "Sheet1":[TABLE="width: 300"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Day:[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
What i want to do this copy all cell in sheet1 and paste it to the worksheet specified in cell B1, and i want to paste value only.

Code:
Sub copy()

Worksheets("Sheet1").Activate
Columns("A:M").Select
Selection.copy
Worksheets(Worksheets("Sheet1").Range("B1").Value).Activate
ActiveSheet.Paste



End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Try

Worksheets("Sheet1").Activate
Columns("A:M").Select
Selection.Copy
Worksheets(Worksheets("Sheet1").Range("B1").Value).Activate
ActiveSheet.Range("a1").Select
ActiveSheet.Paste
 
Upvote 0
No Works perfectly, does the sheet in "B1" have a strange name or does it actually exist. The code is copying columns "A:M" are you saying you want more than that, then I can see what is wrong.

Kev
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,454
Members
452,514
Latest member
cjkelly15

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