Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro to copy a sheet and delete a macro button

In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy a sheet and delete a macro button

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro to copy a sheet and delete a macro button

Hi,

I'm not sure under which circumstances the button would actually be copied.
try this

Sub Button1_Click()
Dim WB As Workbook
ActiveWorkbook.Sheets("Sheet1").UsedRange.Copy
Set WB = Workbooks.Add
WB.Sheets(1).Range("A1").PasteSpecial
End Sub


Mike

"JoeP" wrote:

In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro to copy a sheet and delete a macro button

Ron,
Thanks for your help. Your code does what I asked for. The sheet that I want
to copy also contains a text box that I want to keep when copied. Is there
anyway to just delete the macro button and not all drawing objects. Thanks
again for your help.

"Ron de Bruin" wrote:

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy a sheet and delete a macro button

Hi Joe

Is it a Forms button ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Ron,
Thanks for your help. Your code does what I asked for. The sheet that I want
to copy also contains a text box that I want to keep when copied. Is there
anyway to just delete the macro button and not all drawing objects. Thanks
again for your help.

"Ron de Bruin" wrote:

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro to copy a sheet and delete a macro button

Yes it is.

"Ron de Bruin" wrote:

Hi Joe

Is it a Forms button ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Ron,
Thanks for your help. Your code does what I asked for. The sheet that I want
to copy also contains a text box that I want to keep when copied. Is there
anyway to just delete the macro button and not all drawing objects. Thanks
again for your help.

"Ron de Bruin" wrote:

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy a sheet and delete a macro button

Use this then

Sub test2()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.Buttons.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Yes it is.

"Ron de Bruin" wrote:

Hi Joe

Is it a Forms button ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Ron,
Thanks for your help. Your code does what I asked for. The sheet that I want
to copy also contains a text box that I want to keep when copied. Is there
anyway to just delete the macro button and not all drawing objects. Thanks
again for your help.

"Ron de Bruin" wrote:

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro to copy a sheet and delete a macro button

Brilliant. Thank you so much!!

"Ron de Bruin" wrote:

Use this then

Sub test2()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.Buttons.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Yes it is.

"Ron de Bruin" wrote:

Hi Joe

Is it a Forms button ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Ron,
Thanks for your help. Your code does what I asked for. The sheet that I want
to copy also contains a text box that I want to keep when copied. Is there
anyway to just delete the macro button and not all drawing objects. Thanks
again for your help.

"Ron de Bruin" wrote:

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Macro to copy a sheet and delete a macro button

You are welcome

For more see this page
http://www.rondebruin.nl/controlsobjectsworksheet.htm


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Brilliant. Thank you so much!!

"Ron de Bruin" wrote:

Use this then

Sub test2()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.Buttons.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Yes it is.

"Ron de Bruin" wrote:

Hi Joe

Is it a Forms button ?


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
Ron,
Thanks for your help. Your code does what I asked for. The sheet that I want
to copy also contains a text box that I want to keep when copied. Is there
anyway to just delete the macro button and not all drawing objects. Thanks
again for your help.

"Ron de Bruin" wrote:

Basic code looks like this

Sub test()
Dim sh As Worksheet

ActiveSheet.Copy
Set sh = ActiveSheet

On Error Resume Next
sh.DrawingObjects.Visible = True
sh.DrawingObjects.Delete
On Error GoTo 0
End Sub


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"JoeP" wrote in message ...
In Excel 2003 I have a worksheet that has a macro button on it. I would like
a macro that will do two things.
1. Make a copy of the sheet into a new workbook.
2. Delete the macro button on the newly created worksheet in the new book
and keep the macro button on the original worksheet.

Any help would be appreciated. Thanks.

JoeP



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
Macro to copy values then delete row for entire sheet Pyrotoy New Users to Excel 18 December 9th 08 12:43 AM
How can I delete a macro when the Delete button is not active? FCR Excel Worksheet Functions 0 March 9th 06 09:43 AM
use macro button to run macro in protected sheet earl Excel Discussion (Misc queries) 3 February 26th 06 10:21 PM
delete a macro button is grayed out. Stan at University of Illinois Excel Worksheet Functions 1 March 10th 05 10:28 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM


All times are GMT +1. The time now is 05:24 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"