+ Reply to Thread
Results 1 to 3 of 3

Copying a sheet from an addin into an open workbook

  1. #1
    OkieViking
    Guest

    Copying a sheet from an addin into an open workbook

    I am trying to copy a worksheet from an addin (Toolbox) into an open workbook
    (TallyFile). For some reason, the code creates a new file and pastes the
    sheet all in my "Copy" line. I have also tried to first activate the
    Tallybase sheet and then copy, but that didn't work either. I have done this
    a few years ago, but I have forgotten how to. What am I doing wrong? The
    pertinent section of code is below.


    Workbooks(TallyFile).Activate
    Sheets.Add
    ActiveSheet.Name = TallyName

    Workbooks("Toolbox.xls").Worksheets("TallyBase").Copy

    ' Cells.Select
    ' Selection.Copy
    Workbooks(TallyFile).Activate
    ActiveSheet.Paste


  2. #2
    Rob Bovey
    Guest

    Re: Copying a sheet from an addin into an open workbook


    Here's one way to do it:

    Workbooks("Toolbox.xls").Worksheets("TallyBase").Copy _
    before:=Workbooks(TallyFile).Worksheets(1)

    --
    Rob Bovey, Excel MVP
    Application Professionals
    http://www.appspro.com/

    * Take your Excel development skills to the next level.
    * Professional Excel Development
    http://www.appspro.com/Books/Books.htm

    "OkieViking" <[email protected]> wrote in message
    news:[email protected]...
    >I am trying to copy a worksheet from an addin (Toolbox) into an open
    >workbook
    > (TallyFile). For some reason, the code creates a new file and pastes the
    > sheet all in my "Copy" line. I have also tried to first activate the
    > Tallybase sheet and then copy, but that didn't work either. I have done
    > this
    > a few years ago, but I have forgotten how to. What am I doing wrong? The
    > pertinent section of code is below.
    >
    >
    > Workbooks(TallyFile).Activate
    > Sheets.Add
    > ActiveSheet.Name = TallyName
    >
    > Workbooks("Toolbox.xls").Worksheets("TallyBase").Copy
    >
    > ' Cells.Select
    > ' Selection.Copy
    > Workbooks(TallyFile).Activate
    > ActiveSheet.Paste
    >




  3. #3
    OkieViking
    Guest

    Re: Copying a sheet from an addin into an open workbook

    Thanks Rob!

    "Rob Bovey" wrote:

    >
    > Here's one way to do it:
    >
    > Workbooks("Toolbox.xls").Worksheets("TallyBase").Copy _
    > before:=Workbooks(TallyFile).Worksheets(1)
    >
    > --
    > Rob Bovey, Excel MVP
    > Application Professionals
    > http://www.appspro.com/
    >
    > * Take your Excel development skills to the next level.
    > * Professional Excel Development
    > http://www.appspro.com/Books/Books.htm
    >
    > "OkieViking" <[email protected]> wrote in message
    > news:[email protected]...
    > >I am trying to copy a worksheet from an addin (Toolbox) into an open
    > >workbook
    > > (TallyFile). For some reason, the code creates a new file and pastes the
    > > sheet all in my "Copy" line. I have also tried to first activate the
    > > Tallybase sheet and then copy, but that didn't work either. I have done
    > > this
    > > a few years ago, but I have forgotten how to. What am I doing wrong? The
    > > pertinent section of code is below.
    > >
    > >
    > > Workbooks(TallyFile).Activate
    > > Sheets.Add
    > > ActiveSheet.Name = TallyName
    > >
    > > Workbooks("Toolbox.xls").Worksheets("TallyBase").Copy
    > >
    > > ' Cells.Select
    > > ' Selection.Copy
    > > Workbooks(TallyFile).Activate
    > > ActiveSheet.Paste
    > >

    >
    >
    >


+ 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