ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying a sheet from an addin into an open workbook (https://www.excelbanter.com/excel-programming/327600-copying-sheet-addin-into-open-workbook.html)

OkieViking

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").C opy

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


Rob Bovey

Copying a sheet from an addin into an open workbook
 

Here's one way to do it:

Workbooks("Toolbox.xls").Worksheets("TallyBase").C opy _
befo=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" wrote in message
...
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").C opy

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




OkieViking

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").C opy _
befo=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" wrote in message
...
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").C opy

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






All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com