Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to copy commandbuttons


Hi,

I have a worksheet (sheet1) with four commandbuttons on row1 and I have
added a new worksheet (sheet2). When I unprotect sheet1, activate the
button "Design Mode" on the "Control Toolbox" toolbar, copy row1 and
paste it as row1 on sheet2, the commandbuttons are also copied.
When I record this with the macro recorder (see code below) and play
the macro afterwards it copies row1 but the commandbuttons are NOT
copied.
What do I need to change to also copy these commandbuttons? Thanks in
advance!


Code:
--------------------
Sheets("Sheet1").Select
Sheets.Add
Sheets("Sheet1").Select
ActiveSheet.Unprotect
Rows("1:1").Select
Selection.Copy
Sheets("Sheet2").Select
Rows("1:1").Select
ActiveSheet.Paste
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=564659

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default How to copy commandbuttons

leonidas,

Use the commandbuttons from the Forms commandbar, rather than the commandbuttons from the Control
Toolbox. You will need to assign a macro rather than use a click event, but the forms
commandbuttons can have their properties set to be moved and sized with a range, which makes them
'copy-able' through code.

HTH,
Bernie
MS Excel MVP


"leonidas" wrote in message
...

Hi,

I have a worksheet (sheet1) with four commandbuttons on row1 and I have
added a new worksheet (sheet2). When I unprotect sheet1, activate the
button "Design Mode" on the "Control Toolbox" toolbar, copy row1 and
paste it as row1 on sheet2, the commandbuttons are also copied.
When I record this with the macro recorder (see code below) and play
the macro afterwards it copies row1 but the commandbuttons are NOT
copied.
What do I need to change to also copy these commandbuttons? Thanks in
advance!


Code:
--------------------
Sheets("Sheet1").Select
Sheets.Add
Sheets("Sheet1").Select
ActiveSheet.Unprotect
Rows("1:1").Select
Selection.Copy
Sheets("Sheet2").Select
Rows("1:1").Select
ActiveSheet.Paste
--------------------


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=564659



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
Help to loop Commandbuttons vertically davidm Excel Programming 17 January 30th 06 12:04 AM
CommandButtons Mats Samson Excel Programming 4 January 17th 06 02:19 PM
Commandbuttons PCOR Excel Programming 1 May 11th 04 11:21 PM
Do While, OnTime and CommandButtons John Petty Excel Programming 1 November 23rd 03 12:23 AM
commandbuttons properties Rui[_2_] Excel Programming 2 November 5th 03 04:07 PM


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