+ Reply to Thread
Results 1 to 3 of 3

Inserting a worksheet into an open workbook via VBA code

  1. #1
    manillla
    Guest

    Inserting a worksheet into an open workbook via VBA code

    I am trying to insert a worksheet from file into an open workbook with VBA
    code. I was wandering what the code needs to look like.
    Thanks

  2. #2
    Norman Jones
    Guest

    Re: Inserting a worksheet into an open workbook via VBA code

    "manillla" <[email protected]> wrote in message
    news:[email protected]...
    >I am trying to insert a worksheet from file into an open workbook with VBA
    > code. I was wandering what the code needs to look like.
    > Thanks



    Hi Manilla

    Try something like:

    Sub Tester()

    Workbooks("Book1.xls").Sheets("YourSheetName").Copy _
    After:=Workbooks("Book2.xls"). _
    Sheets(Workbooks("Book2").Sheets.Count)
    End Sub

    ---
    Regards,
    Norman





  3. #3
    Norman Jones
    Guest

    Re: Inserting a worksheet into an open workbook via VBA code

    Hi Manilla,

    > Sub Tester()
    >
    > Workbooks("Book1.xls").Sheets("YourSheetName").Copy _
    > After:=Workbooks("Book2.xls"). _
    > Sheets(Workbooks("Book2").Sheets.Count)
    > End Sub


    should have read:

    Sub Tester()

    Workbooks("Book1.xls").Sheets("YourSheetName").Copy _
    After:=Workbooks("Book2.xls"). _
    Sheets(Workbooks("Book2.xls").Sheets.Count)
    End Sub


    (The ".xls" was missing from the last instance of "Book2").


    ---
    Regards,
    Norman



    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > "manillla" <[email protected]> wrote in message
    > news:[email protected]...
    >>I am trying to insert a worksheet from file into an open workbook with VBA
    >> code. I was wandering what the code needs to look like.
    >> Thanks

    >
    >
    > Hi Manilla
    >
    > Try something like:
    >
    > Sub Tester()
    >
    > Workbooks("Book1.xls").Sheets("YourSheetName").Copy _
    > After:=Workbooks("Book2.xls"). _
    > Sheets(Workbooks("Book2").Sheets.Count)
    > End Sub
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1