Loading
Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports



Results 1 to 4 of 4

Thread: Copy Worksheet From One Workbook To Another Workbook

  1. #1
    Join Date
    19th April 2007
    Posts
    2

    Copy Worksheet From One Workbook To Another Workbook

    Hello all,

    First off, I'm *very* new to macros, so please go easy on me. Thanks!

    Here's the deal: I need a macro that copies one worksheet (from a workbook containing only 1 worksheet) named "CME Case Questions" and pastes into another (existing) workbook that has several worksheets already. The names of both workbooks will change from day to day, however. I then need both workbooks to be saved in the their respective directories..

    Thanks in advance,
    David

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    12th September 2006
    Location
    The Great State of Texas
    Posts
    4,324

    Re: Copy Worksheet From One Workbook To Another Workbook

    Code:
        ' put copy after last sheet
        Workbooks("CME Case Questions").Sheets(1).Copy _
        After:=Workbooks("OtherWorkBook").Sheets.Count
        
        ' put copy before first sheet
        Workbooks("CME Case Questions").Sheets("Sheet1").Copy _
        Before:=Workbooks("OtherWorkBook").Sheets(1)
        
        ' copy before (or after) some particular sheet
        Workbooks("CME Case Questions").Sheets("Sheet1").Copy _
        Before:=Workbooks("OtherWorkBook").Sheets("SheetName")

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    19th April 2007
    Posts
    2

    Re: Copy Worksheet From One Workbook To Another Workbook

    Thanks--I appreciate the help, but is there a generic code for Workbooks("OtherWorkBook")?? The name of the workbook I will be copying to (and from) will be changing hourly..

    Is there any way I can use a macro to copy a worksheet from one active workbook into another inactive workbook, regardless of the workbook's name?

    Thanks again for the help!

    David

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    12th September 2006
    Location
    The Great State of Texas
    Posts
    4,324

    Re: Copy Worksheet From One Workbook To Another Workbook

    is there a generic code for Workbooks("OtherWorkBook")??
    Use a variable:

    Code:
    Dim strWB as string
    ' open this month's workbook (e.g., Revenue_Apr07) 
    strWB = "Revenue_" & format(today, "mmmyy")
    Workbooks.Open(strWB)
    With Workbooks(strWB)
       .Sheet1.Range("A1") = Hello World"
       ...

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Add Workbook And Copy Worksheet
    By spud in forum EXCEL HELP
    Replies: 4
    Last Post: February 14th, 2007, 22:12
  2. Copy a worksheet from one workbook to another
    By BVic in forum EXCEL HELP
    Replies: 1
    Last Post: August 9th, 2006, 02:22
  3. Replies: 15
    Last Post: January 28th, 2005, 18:27

Bookmarks

Posting Permissions

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