![]() |
Need help with VBA
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. |
Need help with VBA
see ,page on Getting Started with Macros
http://www.mvps.org/dmcritchie/excel/getstarted.htm --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "VJ7777" wrote in message ... 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. |
Need help with VBA
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. |
Need help with VBA
David McRitchie's site http://www.mvps.org/dmcritchie/excel....htm#tutorials the vba tutorials are below the excel tutorials. This has good info as well (for Excel) http://msdn.microsoft.com/office/und.../odc_super.asp -- Regards, Tom Ogilvy "VJ7777" wrote in message ... 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. |
Need help with VBA
"gocush" wrote: 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. Thank you. I can use each of your solutions in multiple situations and will play with them tonight. I suspect I failed to pinpoint the real culprit in my example - the button - which probably looks for the macro name that was on the worksheet of the old workbook rather than the changed name. I have had very little luck in finding and following Microsoft's explanation of how to deal with buttons. |
Need help with VBA
"Tom Ogilvy" wrote: David McRitchie's site http://www.mvps.org/dmcritchie/excel....htm#tutorials the vba tutorials are below the excel tutorials. This has good info as well (for Excel) http://msdn.microsoft.com/office/und.../odc_super.asp -- Regards, Tom Ogilvy "VJ7777" wrote in message ... 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. Thank you. Now I have a place to start. The Microsoft manual didn't do it. |
Need help with VBA
"David McRitchie" wrote: see ,page on Getting Started with Macros http://www.mvps.org/dmcritchie/excel/getstarted.htm --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm Search Page: http://www.mvps.org/dmcritchie/excel/search.htm "VJ7777" wrote in message ... 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. Thank you. Now I have a place to start. The Microsoft manual just didn't do it. |
All times are GMT +1. The time now is 12:41 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com