Consulting

Results 1 to 5 of 5

Thread: Copy worksheets to new workbooks

  1. #1

    Copy worksheets to new workbooks

    Hi all,

    Hoping for some help, it would be greatly appreciated. I'm new to vba and my task at hand involves copying worksheets from multiple workbooks and pasteing them into a new workbook with multiple sheets.

    I have 12 workbooks to start with. File names are Jan2006 thru Dec2006. Each workbook has about 50+ worksheets, named T01 thru T58.

    What I would like to happen is to copy the range("C4:O58") of each worksheet, titled T01, from each workbook and paste them into a new workbook, to be named table01. So the new work book will be named table01, and have 12 worksheets, named Jan, Feb, Mar... Dec, corresponding with the workbook they are coming from.

    Could I have some help with a template to get me started. If you need anymore details please let me know. I really appreciate the help. thank you

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Untested.
    [vba]cSheets = Application.SheetsInNewWorkbook
    Application.SheetsInNewWorkbook = 12
    Set oWB = Workbooks.Add
    Application.SheetsInNewWorkbook = cSheets
    For i = 1 To 12
    Workbooks(Format(DateSerial(Year(Date) - 1, 1, 1), "mmmyyyy&quot).Open
    ActiveWorkbook.Worksheets("T01&quot.Range("C4:O58&quot.Copy oWB.Worksheets(i).Range("A1&quot
    oWB.Worksheets(i).Name = Format(DateSerial(Year(Date), 1, 1), "mmm&quot
    Next i[/vba]
    Last edited by Bob Phillips; 03-18-2007 at 08:46 PM.

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Malcolm, help!

  4. #4
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Hope I got the lines correct Bob...
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Thanks Steve. No idea why this has started to happen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •