How do I make VBA code usable on all worksheets of a workbook?

T

tarobb

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?
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top