ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I make VBA code usable on all worksheets of a workbook? (https://www.excelbanter.com/excel-programming/427880-how-do-i-make-vba-code-usable-all-worksheets-workbook.html)

tarobb

How do I make VBA code usable on all worksheets of a workbook?
 
Hello all,
I want to find the best method for using VBA code on my worksheets.
I have an Excell workbook that has copies of the same worksheet for every
month of the year. I have custom formating and calculations. I use the
calendar control to enter dates in cells and a command button to copy data
and display funtions to a new sheet at the end of the month.
Right now the copy routine is in a module and it sets the page up ok. I
also have code on each sheet code page to run the command button and use the
calendar control.
Is there a way to make the cmdBtn and calendar work by either VBA code copy
or moving the code to a single place that all sheets can have access to them?


Dave Peterson

How do I make VBA code usable on all worksheets of a workbook?
 
You may want to move all that code to a different workbook and save that
workbook as an addin.

Then create a toolbar (or add more items to the to the menubar) to give access
to the macro that does all the work.

Then you can use:
Tools|Addins (xl2003 menus)
to install (and enable/disable) this addin
(or you can just open it when you need to)

For additions to the worksheet menu bar, I really like the way John Walkenbach
does it in his menumaker workbook:
http://j-walk.com/ss/excel/tips/tip53.htm

Here's how I do it when I want a toolbar:
http://www.contextures.com/xlToolbar02.html
(from Debra Dalgleish's site)

In xl2007, those toolbars and menu modifications will show up under the addins.

And if you use xl2007:

If you want to learn about modifying the ribbon, you can start at Ron de Bruin's
site:
http://www.rondebruin.nl/ribbon.htm
http://www.rondebruin.nl/qat.htm -- For macros for all workbooks (saved as an
addin)
or
http://www.rondebruin.nl/2007addin.htm

tarobb wrote:

Hello all,
I want to find the best method for using VBA code on my worksheets.
I have an Excell workbook that has copies of the same worksheet for every
month of the year. I have custom formating and calculations. I use the
calendar control to enter dates in cells and a command button to copy data
and display funtions to a new sheet at the end of the month.
Right now the copy routine is in a module and it sets the page up ok. I
also have code on each sheet code page to run the command button and use the
calendar control.
Is there a way to make the cmdBtn and calendar work by either VBA code copy
or moving the code to a single place that all sheets can have access to them?


--

Dave Peterson


All times are GMT +1. The time now is 05:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com