Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default One button, one macro, several sheets

I have a workbook with a lot of simular sheets. On each sheet I want to have
the same button that directs the user to a central sheet (where, of course,
is a button which redirects the user to where he/she came from).

To create one button is not the problem. To copy the button to all the other
sheets, whithout having to rename the "Commandbutton1" and to copy the VBA
code to all the other sheets is the problem.

So, I am looking for a central place for the macro (This Worksheet??) and a
way to in the first place and a way to "tell" my commandbutton where to look
for that macro.

Thanks for your help in advance,

Henk

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default One button, one macro, several sheets



Create your sub in a module. The sub should be Public and accessible from
any sheet. Then assign the button on each sheet to the same sub. This will
work for both a Forms or a Controls button
--
Gary''s Student - gsnu200770


"Henk" wrote:

I have a workbook with a lot of simular sheets. On each sheet I want to have
the same button that directs the user to a central sheet (where, of course,
is a button which redirects the user to where he/she came from).

To create one button is not the problem. To copy the button to all the other
sheets, whithout having to rename the "Commandbutton1" and to copy the VBA
code to all the other sheets is the problem.

So, I am looking for a central place for the macro (This Worksheet??) and a
way to in the first place and a way to "tell" my commandbutton where to look
for that macro.

Thanks for your help in advance,

Henk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default One button, one macro, several sheets

Thanks for your quick answer.

It is exactly how I thought it should work, but ................ it does not.

As far as I know the only way to assign a macro to a command button, is to
double click the button in Design Mode. But then you are directed to a
Private sub with the name of the command button in the sheet where the button
is. I have not found a way yet to tell the button where to look for the macro
it has to execute.

Using a Form control on my worksheet, results in a button that is assigned
to the right macro, but can not be invoked whether it is in Design Mode or
not.

The logic is clear to me, but I do not know how to do it.

"Gary''s Student" wrote:



Create your sub in a module. The sub should be Public and accessible from
any sheet. Then assign the button on each sheet to the same sub. This will
work for both a Forms or a Controls button
--
Gary''s Student - gsnu200770


"Henk" wrote:

I have a workbook with a lot of simular sheets. On each sheet I want to have
the same button that directs the user to a central sheet (where, of course,
is a button which redirects the user to where he/she came from).

To create one button is not the problem. To copy the button to all the other
sheets, whithout having to rename the "Commandbutton1" and to copy the VBA
code to all the other sheets is the problem.

So, I am looking for a central place for the macro (This Worksheet??) and a
way to in the first place and a way to "tell" my commandbutton where to look
for that macro.

Thanks for your help in advance,

Henk

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default One button, one macro, several sheets

1. first create a macro using, for example, the Recorder
2. bring up the Forms ToolBar
3. put a button on a sheet

the Assign Macro dialog box will appear.

4. under Macro name, ignore Button1_Click and select the sub created in step
#1
5. click outside the button to exit Edit mode
--
Gary''s Student - gsnu200770


"Henk" wrote:

Thanks for your quick answer.

It is exactly how I thought it should work, but ................ it does not.

As far as I know the only way to assign a macro to a command button, is to
double click the button in Design Mode. But then you are directed to a
Private sub with the name of the command button in the sheet where the button
is. I have not found a way yet to tell the button where to look for the macro
it has to execute.

Using a Form control on my worksheet, results in a button that is assigned
to the right macro, but can not be invoked whether it is in Design Mode or
not.

The logic is clear to me, but I do not know how to do it.

"Gary''s Student" wrote:



Create your sub in a module. The sub should be Public and accessible from
any sheet. Then assign the button on each sheet to the same sub. This will
work for both a Forms or a Controls button
--
Gary''s Student - gsnu200770


"Henk" wrote:

I have a workbook with a lot of simular sheets. On each sheet I want to have
the same button that directs the user to a central sheet (where, of course,
is a button which redirects the user to where he/she came from).

To create one button is not the problem. To copy the button to all the other
sheets, whithout having to rename the "Commandbutton1" and to copy the VBA
code to all the other sheets is the problem.

So, I am looking for a central place for the macro (This Worksheet??) and a
way to in the first place and a way to "tell" my commandbutton where to look
for that macro.

Thanks for your help in advance,

Henk

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default One button, one macro, several sheets

hi
Or if button already exists, right click it and Assign Macro...
regards
Paul

On Feb 21, 11:12*am, Gary''s Student
wrote:
1. first create a macro using, for example, the Recorder
2. bring up the Forms ToolBar
3. put a button on a sheet

the Assign Macro dialog box will appear.

4. under Macro name, ignore Button1_Click and select the sub created in step
#1
5. click outside the button to exit Edit mode
--
Gary''s Student - gsnu200770



"Henk" wrote:
Thanks for your quick answer.


It is exactly how I thought it should work, but ................ it does not.


As far as I know the only way to assign a macro to a command button, is to
double click the button in Design Mode. But then you are directed to a
Private sub with the name of the command button in the sheet where the button
is. I have not found a way yet to tell the button where to look for the macro
it has to execute.


Using a Form control on my worksheet, results in a button that is assigned
to the right macro, but can not be invoked whether it is in Design Mode or
not.


The logic is clear to me, but I do not know how to do it.


"Gary''s Student" wrote:


Create your sub in a module. *The sub should be Public and accessible from
any sheet. *Then assign the button on each sheet to the same sub. *This will
work for both a Forms or a Controls button
--
Gary''s Student - gsnu200770


"Henk" wrote:


I have a workbook with a lot of simular sheets. On each sheet I want to have
the same button that directs the user to a central sheet (where, of course,
is a button which redirects the user to where he/she came from).


To create one button is not the problem. To copy the button to all the other
sheets, whithout having to rename the "Commandbutton1" and to copy the VBA
code to all the other sheets is the problem.


So, I am looking for a central place for the macro (This Worksheet??) and a
way to in the first place and a way to "tell" my commandbutton where to look
for that macro.


Thanks for your help in advance,


Henk- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default One button, one macro, several sheets

Wonderful!

It is working with the "Form control command-button".

It is not necessary anymore, but if you know a way to get it working with an
"Active X-control Command-button" please let me know.

tHENKs!



" wrote:

hi
Or if button already exists, right click it and Assign Macro...
regards
Paul

On Feb 21, 11:12 am, Gary''s Student
wrote:
1. first create a macro using, for example, the Recorder
2. bring up the Forms ToolBar
3. put a button on a sheet

the Assign Macro dialog box will appear.

4. under Macro name, ignore Button1_Click and select the sub created in step
#1
5. click outside the button to exit Edit mode
--
Gary''s Student - gsnu200770



"Henk" wrote:
Thanks for your quick answer.


It is exactly how I thought it should work, but ................ it does not.


As far as I know the only way to assign a macro to a command button, is to
double click the button in Design Mode. But then you are directed to a
Private sub with the name of the command button in the sheet where the button
is. I have not found a way yet to tell the button where to look for the macro
it has to execute.


Using a Form control on my worksheet, results in a button that is assigned
to the right macro, but can not be invoked whether it is in Design Mode or
not.


The logic is clear to me, but I do not know how to do it.


"Gary''s Student" wrote:


Create your sub in a module. The sub should be Public and accessible from
any sheet. Then assign the button on each sheet to the same sub. This will
work for both a Forms or a Controls button
--
Gary''s Student - gsnu200770


"Henk" wrote:


I have a workbook with a lot of simular sheets. On each sheet I want to have
the same button that directs the user to a central sheet (where, of course,
is a button which redirects the user to where he/she came from).


To create one button is not the problem. To copy the button to all the other
sheets, whithout having to rename the "Commandbutton1" and to copy the VBA
code to all the other sheets is the problem.


So, I am looking for a central place for the macro (This Worksheet??) and a
way to in the first place and a way to "tell" my commandbutton where to look
for that macro.


Thanks for your help in advance,


Henk- Hide quoted text -


- Show quoted text -



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
"Form / Button" Macro for Unhiding Sheets Melissa Excel Discussion (Misc queries) 0 September 5th 08 06:07 PM
Macro button to print sheets populated from drop-down list AB3 Excel Discussion (Misc queries) 7 July 11th 08 01:03 AM
Trying to set Option button values in macro on protected sheets Damon Excel Programming 4 July 9th 05 10:37 PM
Pause macro, add form button to sheet, continue macro when button clicked! Flystar[_15_] Excel Programming 1 May 26th 04 09:45 AM
Creating an "update" button and using a macro to copy data from multiple sheets SPIRITTTJ Excel Programming 1 January 8th 04 05:50 PM


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