SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 29 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


A new standard code module named Module1 has been inserted in your project. Open
Module1 by double-clicking the Modules folder, and then click Module1 to view the Macro
Recorder??“generated code. Listing 1-1 shows the code the Macro Recorder generated for us.
Listing 1-1.Macro Recorder??“Generated Code
Sub MyMacro()
'
' MyMacro Macro
' Enter test data
'
'
Range("A1").Select
ActiveCell.FormulaR1C1 = "Item"
Range("B1").Select
ActiveCell.FormulaR1C1 = "Color"
Range("C1").Select
ActiveCell.FormulaR1C1 = "Quantity"
Range("D1").Select
ActiveCell.FormulaR1C1 = "Price"
Range("E1").Select
ActiveCell.FormulaR1C1 = "Line total"
Range("A2").Select
ActiveCell.FormulaR1C1 = "Shirt"
Range("B2").Select
ActiveCell.FormulaR1C1 = "Red"
Range("C2").Select
ActiveCell.FormulaR1C1 = "5"
Range("D2").Select
ActiveCell.FormulaR1C1 = "6"
CHAPTER 1 n THE MACRO RECORDER AND CODE MODULES 15
2ca983ba3745582e6151dc1b079b2db0
Range("A3").Select
ActiveCell.FormulaR1C1 = "Shirt"
Range("B3").Select
ActiveCell.FormulaR1C1 = "Blue"
Range("C3").Select
ActiveCell.FormulaR1C1 = "4"
Range("D3").Select
ActiveCell.FormulaR1C1 = "7"
Range("A4").Select
ActiveCell.FormulaR1C1 = "Hat"
Range("B4").Select
ActiveCell.FormulaR1C1 = "Black"
Range("C4").Select
ActiveCell.FormulaR1C1 = "10"
Range("D4").Select
ActiveCell.FormulaR1C1 = "8"
Range("A6").Select
ActiveCell.FormulaR1C1 = "Total"
Range("A7").Select
End Sub
Excel 2007 has created a subroutine for us, and we can see each cell we selected and the
data we entered into each.


Pages:
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41