OV Copyright © 2011 Element K Content LLC. All rights reserved. Insert Text Format Text Sort Data Duplicate Data Generate a Report Formatting Worksheets Using Macros
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Selection Property Selection Property
OV Copyright © 2011 Element K Content LLC. All rights reserved. The ActiveSheet Property ActiveSheet Property
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Name Property ActiveSheet.Name = “Conservative" New name of the worksheet New name of the worksheet Old name of the worksheet Old name of the worksheet Name property of the currently active worksheet
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Value Property Range(“A1”).Value = “Hello” A data value assigned to cell A1 A data value assigned to cell A1
OV Copyright © 2011 Element K Content LLC. All rights reserved. Concatenation “Balanced” & “ ” & “Portfolio” “Balanced Portfolio” Concatenation operator Concatenation operator Pieces of text concatenated Single piece of text resulting from the concatenation Single piece of text resulting from the concatenation
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Range Object Range Object
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Select Method Range(“B6:E6”).Select Range object referring to a specific range Range object referring to a specific range Range selected on the worksheet Range selected on the worksheet
OV Copyright © 2011 Element K Content LLC. All rights reserved. The CurrentRegion Property CurrentRegion Property
OV Copyright © 2011 Element K Content LLC. All rights reserved. Data Types String Data Type Integer Data Type Boolean Data Type Classification of data used in a macro Text Positive or negative whole number Positive or negative whole number True/false value
OV Copyright © 2011 Element K Content LLC. All rights reserved. Option Explicit Sub Variables Ex() Dim x As Integer Dim CustName As String Dim CurrentCust As Boolean x = 39 CustName = "John Smith" CurrentCust = False End Sub Variables Statement used to explicitly declare all variables Statements declaring variables in different data types Statements declaring variables in different data types Data assigned to variables Data assigned to variables
OV Copyright © 2011 Element K Content LLC. All rights reserved. x = y = x > 50 PrenCust = CurrentCust And PastCust Operators
OV Copyright © 2011 Element K Content LLC. All rights reserved. For x = 1 To 12 Worksheets.Add After:=Worksheets(x) Next x The For Next Loop For statement Counter variable Code within the loop that is repeated Code within the loop that is repeated Next statement
OV Copyright © 2011 Element K Content LLC. All rights reserved. Dim counter, factorial As Integer Counter = 10 Do factorial = factorial * counter counter = counter – 1 Loop While counter > 0 The Do Loop Do statement Code that gets executed each time Code that gets executed each time While criterion Loop statement
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Count Property Three sheets Worksheets.Count
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Offset Property ActiveCell.Offset(-3, -2) ActiveCell.Offset(3, 2) Column reference Positive values move offset down and right Positive values move offset down and right Negative values move offset up and left Negative values move offset up and left Row reference
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Copy Method ActiveSheet.Copy Data copied to the Clipboard Data copied to the Clipboard Copy method
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Paste Method ActiveSheet.Paste Paste method Data from the Clipboard pasted to the sheet
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Columns Property Columns(“B:E”).Select Column range specified within parentheses Columns property and Select method select a column
OV Copyright © 2011 Element K Content LLC. All rights reserved. The AutoFit Method Columns(B:E).AutoFit AutoFit method
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Address Property ActiveCell.Value = ActiveCell.Address Address property
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Call Statement Sub MasterMac() Call InsertHeader Call FormatHeader Call InsertData Call FormatData End Sub Module containing component macros
OV Copyright © 2011 Element K Content LLC. All rights reserved. The Font Property ActiveCell.Font.Name = “Old English MT” Font property
OV Copyright © 2011 Element K Content LLC. All rights reserved. The End Property Range(“C50”).Select ActiveCell.End(x1Up) End property Direction of the last cell
OV Copyright © 2011 Element K Content LLC. All rights reserved. 1. Which manual formatting tasks will you want to replace with a macro? 2. Which coding technique will you use often when creating macros for formatting data? Reflective Questions