Copy Data to new workbook VBA - am I even close?

andshep

New Member
Joined
Jul 28, 2005
Messages
47
I have a workbook with a variable number of sheets, with variable names, (both variable from week to week), the sheets are all identical in format.

What I am trying to do is copy the same range from each sheet in the workbook to a new workbook. The following code is what I have tried with my limited knowledge. It is supposed to create a new workbook, and then copy the data from each sheet in the original workbook to the same sheet in the new workbook, adding the next lot of data to the bottom of the previous lot. Am I even close or is there a much better way to do this? Thanks for any/all help

Code:
Sub CopyData()

Dim LastPasteRow As Range
Dim wb As Workbook
Dim wb2 As Workbook
Dim ws As Worksheet
      
    Set wb = ActiveWorkbook
    Workbooks.Add
    Set wb2 = ActiveWorkbook
    wb.Activate
    For Each ws In wb.Worksheets
    Range("A6:O36").Select
    Selection.Copy
    wb2.Activate
    Set LastPasteRow = Range("A65536").End(xlUp)
    Range("A" & "LastPasteRow").Select
    ActiveCell.Offset(1, 0).Select
    Selection.Paste
    Application.CutCopyMode = False
    wb.Activate
    Next ws
End Sub

EXcel 2003/Win XP Pro
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Why don't you create a new sheet in your workbook, copy the required data then delete all but your new sheet and resave under a new name?
 
Upvote 0
How about changin:
Code:
    Range("A6:O36").Select 
    Selection.Copy
to
Code:
   ws.Range("A6:O36").Copy
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,195
Members
449,072
Latest member
DW Draft

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