Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Copying Workseet to NewWorkbook

Hi

Can someone please advise on how can I copy active workseet to a new
workbook without copying the macros along with it (the workbook I am copying
the workseet from ahas nacros in it). i.e copy just the sheet & its value but
keeping intact the formating.
All this using VBA.

Thanks a lot in advance for your help
J
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Copying Workseet to NewWorkbook

Hi James,
'-------------------------------
Sub CopySheet()
Dim wshSource As Worksheet, wshDest As Worksheet
Dim wkbDest As Workbook

Set wshSource = ActiveSheet
Set wkbDest = Workbooks.Add(xlWBATWorksheet)
Set wshDest = wkbDest.Worksheets(1)

wshSource.Cells.Copy wshDest.Cells
End Sub
'-----------------------------------

Regards,
Sebastien

"James" wrote:

Hi

Can someone please advise on how can I copy active workseet to a new
workbook without copying the macros along with it (the workbook I am copying
the workseet from ahas nacros in it). i.e copy just the sheet & its value but
keeping intact the formating.
All this using VBA.

Thanks a lot in advance for your help
J

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default Copying Workseet to NewWorkbook

Thank you so much Sebastienm, it works.
Just one question, as my sheet which got copied it also had a Comman Button
with Macro assigned to it, as Button moved over while copying, when you click
it it tries to call the old worksheet to execute the macro. Any way to get
rid of all the Buttons on the new sheet after copy.

Thanks a million

"sebastienm" wrote:

Hi James,
'-------------------------------
Sub CopySheet()
Dim wshSource As Worksheet, wshDest As Worksheet
Dim wkbDest As Workbook

Set wshSource = ActiveSheet
Set wkbDest = Workbooks.Add(xlWBATWorksheet)
Set wshDest = wkbDest.Worksheets(1)

wshSource.Cells.Copy wshDest.Cells
End Sub
'-----------------------------------

Regards,
Sebastien

"James" wrote:

Hi

Can someone please advise on how can I copy active workseet to a new
workbook without copying the macros along with it (the workbook I am copying
the workseet from ahas nacros in it). i.e copy just the sheet & its value but
keeping intact the formating.
All this using VBA.

Thanks a lot in advance for your help
J

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Copying Workseet to NewWorkbook

If the button is:
- a button from the Forms toobar:
wshDest.buttons(1).delete
- a button from the Control Toolbox toolbar
wshDest.oleobjects(1).delete
You can replace the 1 by the name of the button if you know it (should be
displayed in the Name box ie address box when you select the button). eg
wshDest.buttons("button 1").delete
wshDest.oleobjects("button 1").delete

Regards,
Sebastienm

"James" wrote:

Thank you so much Sebastienm, it works.
Just one question, as my sheet which got copied it also had a Comman Button
with Macro assigned to it, as Button moved over while copying, when you click
it it tries to call the old worksheet to execute the macro. Any way to get
rid of all the Buttons on the new sheet after copy.

Thanks a million

"sebastienm" wrote:

Hi James,
'-------------------------------
Sub CopySheet()
Dim wshSource As Worksheet, wshDest As Worksheet
Dim wkbDest As Workbook

Set wshSource = ActiveSheet
Set wkbDest = Workbooks.Add(xlWBATWorksheet)
Set wshDest = wkbDest.Worksheets(1)

wshSource.Cells.Copy wshDest.Cells
End Sub
'-----------------------------------

Regards,
Sebastien

"James" wrote:

Hi

Can someone please advise on how can I copy active workseet to a new
workbook without copying the macros along with it (the workbook I am copying
the workseet from ahas nacros in it). i.e copy just the sheet & its value but
keeping intact the formating.
All this using VBA.

Thanks a lot in advance for your help
J

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
Put a Worksheet in a workseet? Jayna Excel Worksheet Functions 1 April 7th 05 03:02 PM
Newworkbook JonMny Excel Programming 0 August 13th 04 06:03 PM
Insert Details from ListBox onto a NewWorkbook sjvenz[_4_] Excel Programming 1 December 11th 03 05:58 AM
Excel NewWorkbook event Doug Paul Excel Programming 0 September 4th 03 02:47 PM
C# newWorkbook event Doug Paul Excel Programming 0 August 27th 03 04:39 PM


All times are GMT +1. The time now is 02:29 AM.

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

About Us

"It's about Microsoft Excel"