1. I have a macro which works in one worksheet of a workbook. I tried to
use "save as" to create a template which I could insert in other workbooks
but it won't work because it is looking for a different macro name; I don't
know how to re-name the macro
--------------------------------------------------------------
I'm a little confused about your question. When you "Save As" you are
saving the workbook, not the macro. So if you have a Workbook A.xls with a
macro --
Sub MyMacroA() and you want to turn this workbook into a template, then you
click on "Save As", select Template in the File Type box and it will be saved
as Workbook A.xlt -- notice the extention. It will also automatically
contain MyMacroA as well.
On the other hand, if you create a macro: MyMacroB
that you want to be able to use in any workbook that you open, you can save
the macro in you hidden Personal.xls workbook -- This is a pseudo workbook,
with the apparent sole purpose to hold macros that you wish to use in this
manner. It opens in the background whenever you open Excel.
A third interpretation of your intention in you question is "If I have
MyMacro in Workbook A and I want to copy it to Workbook B, how do I do it?
One method: Open both workbooks. Open the
VB Editor. Open the Project
window. Select Workbook A in the Project window. If MyMacro is the only
macro in its module, you can click and drag the macro to Workbook B to copy
the entire module. If there are other macros in this module, then select
only the code lines of MyMacro. Open a module in Workbook B and paste the
code. No need to rename the macro unless there is already a macro in
Workbook B by the same name.
Now if you really want to change the name of a macro, open the VBE, find the
macro and retype its name in the "Sub .....()" statement. For example --
Change: Sub MyMacroA()
To: Sub MyMacroB()
HTH
"VJ7777" wrote:
I taught myself Basic and Fortran in past years but VBA is like Sanskrit to
me. I cannot find a starting place. I have two questions:
1. I have a macro which works in one worksheet of a workbook. I tried to
use "save as" to create a template which I could insert in other workbooks
but it won't work because it is looking for a different macro name; I don't
know how to re-name the macro.
2. I have a workbook whereby I want to protect multiple worksheets. After
protecting two worksheets and saving the file I cannjot open it again because
I have exceeded the 4,000 or 3,000 formats. There is a solution at:
http://groups-beta.google.com/group/...9f7cdf3a4b3e04
but I don't know how to get the macro (macros?) implemented.