Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
"Form / Button" Macro for Unhiding Sheets | Excel Discussion (Misc queries) | |||
Macro button to print sheets populated from drop-down list | Excel Discussion (Misc queries) | |||
Trying to set Option button values in macro on protected sheets | Excel Programming | |||
Pause macro, add form button to sheet, continue macro when button clicked! | Excel Programming | |||
Creating an "update" button and using a macro to copy data from multiple sheets | Excel Programming |