Microsoft Office Tutorials and References
In Depth Information
4.7 Macros
Altogether, the various tracing modes and watch types provide a very powerful set of tools for
debugging code. I use them often!
4.7 Macros
In earlier days, a macro consisted of a series of keystrokes that was recorded and assigned to a hot
key. When a user invoked the hot key, the recording would play and the recorded keystrokes
would be executed.
These days, macros (at least for Microsoft Office) are much more sophisticated. In fact, an Excel
macro is just a special type of subroutine—one that does not have any parameters. (We will
discuss subroutines and parameters in Chapter 6 . )
4.7.1 Recording Macros
Excel has the capability of recording very simple macros. When we ask Excel to record a macro
by selecting Macro Record New Macro from Excel's (not Excel VBA's) Tools menu, it takes
note of our keystrokes and converts them into a VBA subroutine (with no parameters).
For example, suppose we record a macro that does a find and replace, replacing the word "macro"
by the word "subroutine." When we look in the Projects window under the project in which the
macro was recorded, we will find a new subroutine in a standard code module:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 9/13/98 by sr
'
'
Cells.Replace What:="macro", Replacement:="subroutine", _
 
Search JabSto ::




Custom Search