2. Know how to do it without a macro Static Procedure variable that retains value 3. Record or write a macro 4. Test the macro and clean up the code Private Module variable 5. Share with others Public Globally used variable
How to record a macro Declare procedures
1. Choose Developer | Record Macro Private Function can only be called by other Function procedures in the same module 2. Enter a macro name. No space allowed. Public Function can be called by the user and 3. Optional: Specify a keyboard shortcut, macro Function any procedure location, and/or description. Private Sub procedure can only be called by 4. Click OK. Sub other procedures in the same module 5. Perform the actions 6. Choose Developer | Stop Recording. Public Sub Sub procedure / macro can be called by the user or Excel and any procedure
VBA terms Decision Structures
If Condition1 Then Object ............. Noun Statement ...... Sentence statement(s) Property .......... Adjective Procedure ...... Paragraph ElseIf Condition2 Then Method ........... Verb Module ........... Chapter statement(s) Argument........ Adverb Project ............ Book Else statement(s) VBA code colors End If
Black ............... Regular code Select Case Variable
Case expression1 Blue ................. Keywords statement(s) Green .............. Comments Case expression2 Red ................. Errors statement(s) Case else Variable data types statement(s) End Select bln Boolean TRUE (1) or FALSE (0) byt Byte 0 and 255 Loop Structures int Integer -32,768 and 32,767 For counter = Start to Stop Step Increment lng Long -2,147,483,648 and 2,147,483,647 Statement(s) sng Single Up to 7 decimal places Next counter dbl Double Up to 15 decimal places For Each object variable in collection Statement(s) cur Currency Money – up to 4 decimal places. Next dtm Date / 1/1/0100 to 12/31/9999 Do While | Until condition Time 00:00:00 and 23:59:59 Statement(s) str String Text up to 2 billion characters. Loop wkb Workbook A workbook Do Statement(s) wks Worksheet A worksheet Loop While | Until condition rng Range One or more cells
EXCEL VBA Programming By Examples Programming For Complete Beginners Step By Step Illustrated Guide to Mastering Excel VBA Thanh Tran - The full ebook version is just one click away
Download Complete EXCEL VBA Programming By Examples Programming For Complete Beginners Step By Step Illustrated Guide to Mastering Excel VBA Thanh Tran PDF for All Chapters