RE: macros
Hi Eliska,
Thank you for your post, in answer to your question, if you wish to edit a macro which has previously been recorded, follow these steps:
Note: Before undertaking any editing on essential objects you should ensure you are working on a copy of the original, this way should unforeseen errors occur you will not have corrupted your database.
1. Go to Start>Programs>Microsoft Excel to open the application. Go to File>New and open a new spreadsheet. Then go to Window>Unhide to bring the personal macro workbook forward – while you work with Excel this macro workbook remains hidden but when you need to edit a macro that is available to all Excel Workbooks you need to unhide it to be able to work with it.
2. Select “PERSONAL.XLS” and click OK to open the personal macro workbook.
3. Now, you can access the macros already created. Go to Tools>Macros and select Macros.
4. Now you can see all the macros already created and stored in the personal macro workbook. Select “your_macro_name” and click Edit to edit the macro.
5. You will now be viewing the VBA code. You will notice three distinctive windows:
1. The Project Window located to the upper left hand side, which shows you the files currently open.
2. The Properties Window located right below the Project window to the lower left hand corner, which lists the properties of the macros.
3. The Code window, located to the right hand side of the screen. The code window is where you edit the actual code of the macros and the one that you should concentrate on.
You will notice that the code for macro “your_macro_name” begins with “Sub your_macro_name ()” then you have the description of the macro right below it, (you type the description when recording the macro for the first time), then you see in the next line, the keyboard shortcut (if you have set one) – so in essence, the first couple of lines of code give you a quick summary of the macro.
6. If you wish you can now make changes to the text of your macro, remember do not change any of the code which is present, unless you are absolutely sure that your changes will not affect the running of the macro. Keep everything within the Sub xxx() and End Sub indicators.
7. Now go to File>Save PERSONAL.XLS and save the macro changes within the personal macro workbook. Then go to File>Close and Return to Microsoft Excel to close the macro within Visual Basic.
I hope that has helped a bit, Visual Basic in much more depth is covered in our VBA courses, regards Pete.