Copy and Paste Multiple Worksheet Macro

ty3314

New Member
Joined
May 17, 2011
Messages
4
I am fairly new to VBA and am struggling with this. I was hoping that you guys out there who are far smarter than I would have a solution. I am working on a macro that will copy and paste from and an unknown number of sheets into one master sheet all within the same workbook. I want to paste information starting in row 1 in the next empty column. The problem is that the range to be copied from each sheet starts in column B and can vary in size as well. Here is the code I have:

Sub CompileEntries()
Dim ws As Integer
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> "Master" Then
ws.Range("B1").CurrentRegion.Copy
Worksheets("Master").Activate
Range("IV1").Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(0, 1).Select
ActiveSheet.Paste
End If
Next ws
End Sub


Any help would be greatly appreciated. One day I hope I am knowledgeable enough with VBA to return the favor.

Ty
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi ty3314,

Welcome to the MrExcel forum!!

With regards to your macro, replace this line...

Code:
Dim ws As Integer

...with this line:

Code:
Dim ws As Worksheet

and see how that goes.

HTH

Robert
 
Upvote 0
Thanks for the reply Trebor, It still seems to not like the line:

ws.Range("B1").CurrentRegion.Copy
 
Upvote 0
Not sure as it worked for me :confused:

What's the error message being returned?
 
Upvote 0
It says Run-time Erro '1004"
Paste Method of Worksheet class failed.


Thanks for helping me out Trebor. I really appreciate it!
 
Upvote 0
Thanks for helping me out Trebor. I really appreciate it!

You're welcome ;)

It says Run-time Error '1004':

I'd say the tab (or tabs) are protected. Make sure they're all unprotected and try again.

HTH

Robert
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

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