Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dave Peterson
 
Posts: n/a
Default Command Button VBA code

It sounds like you have different buttons on the sheets.

There's a commandbutton on the control toolbox toolbar that has code associated
with its click event. This gets copied when the worksheet gets copied.

There's a button on the Forms toolbar that can have a macro assigned to it.
This code doesn't automatically get copied.

If you rightclick on a button and see "assign macro", it's a Forms toolbar
button. If you don't see that option, it's from the control toolbox toolbar.

(It sounds like the simplest approach for you would be to replace the forms
toolbar buttons with control toolbox toolbar buttons (and move/copy/adjust the
code).)

Terry wrote:

Can anyone help? I have a xls file OfficeXP. I have
command buttons on it with vba code behind the buttons.
In one file that I have when I use the copy sheet function
it copies the button and the code behind the button to a
new sheet in the same file. In the other file when a
sheet is copied the button is copied but it does not have
any coding behind it. Why would these behave
differently? I want the code copied with the sheet and
button.
Thanks for any help..


--

Dave Peterson
  #2   Report Post  
Terry
 
Posts: n/a
Default

Thank you. Appreciate your help.
Thought you might like to know. It was not a form button
(no assign macro). Therefore, I figured maybe it was
corrupt some how or due to being an earlier version
brought into excel 2002. Therefore, I copied the coding
and created a new button and pasted it into. Copied the
sheet and it worked. Before that when I copied a sheet it
copied the button but gave it a new name cmdbutton1
without code.
Thank you for your help. I should have tried a new button
in the first place.

-----Original Message-----
It sounds like you have different buttons on the sheets.

There's a commandbutton on the control toolbox toolbar

that has code associated
with its click event. This gets copied when the

worksheet gets copied.

There's a button on the Forms toolbar that can have a

macro assigned to it.
This code doesn't automatically get copied.

If you rightclick on a button and see "assign macro",

it's a Forms toolbar
button. If you don't see that option, it's from the

control toolbox toolbar.

(It sounds like the simplest approach for you would be to

replace the forms
toolbar buttons with control toolbox toolbar buttons (and

move/copy/adjust the
code).)

Terry wrote:

Can anyone help? I have a xls file OfficeXP. I have
command buttons on it with vba code behind the buttons.
In one file that I have when I use the copy sheet

function
it copies the button and the code behind the button to a
new sheet in the same file. In the other file when a
sheet is copied the button is copied but it does not

have
any coding behind it. Why would these behave
differently? I want the code copied with the sheet and
button.
Thanks for any help..


--

Dave Peterson
.

  #3   Report Post  
Dave Peterson
 
Posts: n/a
Default

Glad you got it working.

Terry wrote:

Thank you. Appreciate your help.
Thought you might like to know. It was not a form button
(no assign macro). Therefore, I figured maybe it was
corrupt some how or due to being an earlier version
brought into excel 2002. Therefore, I copied the coding
and created a new button and pasted it into. Copied the
sheet and it worked. Before that when I copied a sheet it
copied the button but gave it a new name cmdbutton1
without code.
Thank you for your help. I should have tried a new button
in the first place.

-----Original Message-----
It sounds like you have different buttons on the sheets.

There's a commandbutton on the control toolbox toolbar

that has code associated
with its click event. This gets copied when the

worksheet gets copied.

There's a button on the Forms toolbar that can have a

macro assigned to it.
This code doesn't automatically get copied.

If you rightclick on a button and see "assign macro",

it's a Forms toolbar
button. If you don't see that option, it's from the

control toolbox toolbar.

(It sounds like the simplest approach for you would be to

replace the forms
toolbar buttons with control toolbox toolbar buttons (and

move/copy/adjust the
code).)

Terry wrote:

Can anyone help? I have a xls file OfficeXP. I have
command buttons on it with vba code behind the buttons.
In one file that I have when I use the copy sheet

function
it copies the button and the code behind the button to a
new sheet in the same file. In the other file when a
sheet is copied the button is copied but it does not

have
any coding behind it. Why would these behave
differently? I want the code copied with the sheet and
button.
Thanks for any help..


--

Dave Peterson
.


--

Dave Peterson
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
nine digit zip code won't print in mail merge Durham Excel Discussion (Misc queries) 11 July 1st 08 12:34 PM
Sales per dealer code Tray Excel Discussion (Misc queries) 5 January 21st 05 03:05 AM
Code not working and can't see why Steve Excel Discussion (Misc queries) 3 December 31st 04 03:12 PM
Often-Used Code not working in a new Workbook Steve Excel Discussion (Misc queries) 2 December 16th 04 11:55 PM
Problem with Date format from VBA code twig Excel Discussion (Misc queries) 3 December 7th 04 06:01 PM


All times are GMT +1. The time now is 11:10 AM.

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"