Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sheet module VBA not copied

Please help if you are able.

I have found that if I manually copy a sheet by right
click on the sheet tab and select "move or copy" then send
the sheet to another workbook it takes the VBA code stored
in the sheet module with it.

But, if I run the VBA to do this, the VBA code stored in
the sheet module is not included in the copy. I need to be
able to do this from code. Can someone supply me with the
VBA to do this (Excel XP/Win 2000)?

Your example code will be most appreciated. Thanks in
advance for your assistance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Sheet module VBA not copied

ActiveSheet.Copy

will copy the sheet with the code in a new workbook

Or this between workbooks
book2.xls must be open

Sub test()
Dim mybook As Workbook
Dim basebook As Workbook
Set basebook = ThisWorkbook
Set mybook = Workbooks("book2.xls")
basebook.Worksheets(1).Copy after:= _
mybook.Sheets(mybook.Sheets.Count)
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"moonbeam" wrote in message ...
Please help if you are able.

I have found that if I manually copy a sheet by right
click on the sheet tab and select "move or copy" then send
the sheet to another workbook it takes the VBA code stored
in the sheet module with it.

But, if I run the VBA to do this, the VBA code stored in
the sheet module is not included in the copy. I need to be
able to do this from code. Can someone supply me with the
VBA to do this (Excel XP/Win 2000)?

Your example code will be most appreciated. Thanks in
advance for your assistance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copied from web page to excel sheet and cant remove from sheet mitch Excel Worksheet Functions 2 May 4th 10 07:58 PM
copied from web page to excel sheet and cant remove from sheet mitch Excel Worksheet Functions 0 May 4th 10 05:38 PM
copied formulas refer to destination sheet not source sheet Dantron Excel Worksheet Functions 2 October 21st 09 09:51 PM
Range selection in a sheet module raj Excel Programming 2 December 18th 03 08:52 PM
Variable from a sheet module in a class module in XL XP hglamy[_2_] Excel Programming 2 October 14th 03 05:48 PM


All times are GMT +1. The time now is 10:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"