Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 276
Default copy sheet complete with command buttons and code into other workbook !!!

I have code that copies the range A1:AB43 from a sheet in say workbook 1
into workbook 2.
But i have just realised that the command buttons and the code in that sheet
are not being pasted , but only tyhe values.
I am using this code to copy paste :

Workbooks("Workbook1").Activate
Application.DisplayAlerts = False
With ActiveWorkbook.Sheets("SheetA")
.Select
.Range("a1:ab43").Copy ' <============ Does this copy also the button
and code ??
Workbooks("Workbook2").Activate
Sheets.Add
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.ColumnWidth = 10
Columns("C:AA").Select
Selection.ColumnWidth = 5
ActiveSheet.Name = "SheetA"
Sheets("SheetA").Range("A1:AB43").PasteSpecial xlPasteAll ' <===== This
is not pasting the Buttons and code also
Range("A1").Select
End With

Corey....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default copy sheet complete with command buttons and code into other workbook !!!

Corey,
You need to copy the whole sheet, not just a range.
Record a macro to get the code.

NickHK

"Corey" wrote in message
...
I have code that copies the range A1:AB43 from a sheet in say workbook 1
into workbook 2.
But i have just realised that the command buttons and the code in that

sheet
are not being pasted , but only tyhe values.
I am using this code to copy paste :

Workbooks("Workbook1").Activate
Application.DisplayAlerts = False
With ActiveWorkbook.Sheets("SheetA")
.Select
.Range("a1:ab43").Copy ' <============ Does this copy also the button
and code ??
Workbooks("Workbook2").Activate
Sheets.Add
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.ColumnWidth = 10
Columns("C:AA").Select
Selection.ColumnWidth = 5
ActiveSheet.Name = "SheetA"
Sheets("SheetA").Range("A1:AB43").PasteSpecial xlPasteAll ' <=====

This
is not pasting the Buttons and code also
Range("A1").Select
End With

Corey....




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default copy sheet complete with command buttons and code into other workbook !!!

Corey,
Looks like buttons from the Control Toolbox don't get copied.
You can use buttons from the Forms toolbar without a problem.
Another way to go is to copy the sheet and then delete what you
don't want from the new sheet...
Worksheets("SheetA").Copy after := Worksheets("SheetC")
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html


"Corey" wrote in message ...
I have code that copies the range A1:AB43 from a sheet in say workbook 1
into workbook 2.
But i have just realised that the command buttons and the code in that sheet
are not being pasted , but only tyhe values.
I am using this code to copy paste :

Workbooks("Workbook1").Activate
Application.DisplayAlerts = False
With ActiveWorkbook.Sheets("SheetA")
.Select
.Range("a1:ab43").Copy ' <============ Does this copy also the button
and code ??
Workbooks("Workbook2").Activate
Sheets.Add
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.ColumnWidth = 10
Columns("C:AA").Select
Selection.ColumnWidth = 5
ActiveSheet.Name = "SheetA"
Sheets("SheetA").Range("A1:AB43").PasteSpecial xlPasteAll ' <===== This
is not pasting the Buttons and code also
Range("A1").Select
End With

Corey....


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default copy sheet complete with command buttons and code into other workb

Pls try this one

Sub SheetMove()
Dim wbD As Workbook
Dim wbT As Workbook
Set wbD = Workbooks(ThisWorkbook.Name) 'Source workbook name
Set wbT = Workbooks("sample") ' Destination workbook name
wbD.Sheets(1).Copy befo=wbT.Sheets(1)
End Sub

don't forget me rate

"Corey" wrote:

I have code that copies the range A1:AB43 from a sheet in say workbook 1
into workbook 2.
But i have just realised that the command buttons and the code in that sheet
are not being pasted , but only tyhe values.
I am using this code to copy paste :

Workbooks("Workbook1").Activate
Application.DisplayAlerts = False
With ActiveWorkbook.Sheets("SheetA")
.Select
.Range("a1:ab43").Copy ' <============ Does this copy also the button
and code ??
Workbooks("Workbook2").Activate
Sheets.Add
Sheets("Sheet1").Select
Columns("A:B").Select
Selection.ColumnWidth = 10
Columns("C:AA").Select
Selection.ColumnWidth = 5
ActiveSheet.Name = "SheetA"
Sheets("SheetA").Range("A1:AB43").PasteSpecial xlPasteAll ' <===== This
is not pasting the Buttons and code also
Range("A1").Select
End With

Corey....



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
Workbook with 40 sheets, want complete copy without formulaes Johannes Excel Discussion (Misc queries) 1 July 29th 09 04:44 AM
Code for Command Buttons Ayman Excel Discussion (Misc queries) 1 November 3rd 08 08:37 PM
Help...Code to copy sheet from closed workbook [email protected] Excel Discussion (Misc queries) 1 March 28th 07 08:52 PM
Command buttons and code - help!! Lindsey M Excel Programming 1 March 27th 05 09:34 PM
My Command Buttons keep floating on the sheet??? alondon Excel Programming 2 November 28th 04 12:35 AM


All times are GMT +1. The time now is 02:31 PM.

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"