Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Macros in Excel Franco Musso. ActiveCell.Offset.

Similar presentations


Presentation on theme: "Introduction to Macros in Excel Franco Musso. ActiveCell.Offset."— Presentation transcript:

1 Introduction to Macros in Excel Franco Musso

2 ActiveCell.Offset

3 ActiveCell.Offset(2,1).Select Two rows down One column to the right

4 ActiveCell.Offset(-2,-1).Value Two rows up One column to the left

5 ActiveCell.Offset(-2,-1).Value

6 ActiveCell.Offset(-2,-1).Value = “Franco”

7 Conditional Macros

8 ActiveCell.ValueActiveCell.Offset(1,2).Value = Equals <> Does not equal < Is Less than > Is Greater then <= Is Less than or Equal to >= Is Greater than or Equal to “text” Text value “” Blank

9 IF statements If condition Then Action if true Else: Action if false End if

10 IF statements If condition1 Then Action if true ElseIf condition2 Then Action if true ElseIf condition3 Then Action if true End if

11 IF statements If condition1 Then Action if true End if If condition1 Then Action if true End if If condition1 Then Action if true End if

12 Do Loops

13 Do While Repeat while a condition is true e.g. while a cell is not blank Do Until Repeat until a condition is true e.g. while a cell is not blank

14 Do Loop: Syntax Do Until Criteria Actions to perform Loop

15 Do Loop: Syntax Do Until Criteria Actions to perform ActiveCell.Offset(1,0).Select Loop

16 Do Loop: Example Do Until ActiveCell = “” Selection.Font.Bold = True ActiveCell.Offset(1,0).Select Loop

17 Interactive Macros

18 Sheetname = inputbox(“SheetSelector”,”Type a worksheet name:”) Worksheets(Sheetname).Activate

19 Providing Confirmation

20 Method 1: Message Box MsgBox (“Worksheet Updated”)

21 Method 2: Type into sheet ActiveCell.Value = “Worksheet Updated”

22 Method 2: Type into sheet ActiveCell.Value = “Worksheet updated on ” & Now

23 Method 2: Type into sheet userName = inputbox(“Type name here:”,”Who are you?”) ActiveCell.Value = “Worksheet updated by ” & userName & “ on “ & Now

24 Screen Flicker

25 Application.ScreenUpdating =False =True

26 Snippets


Download ppt "Introduction to Macros in Excel Franco Musso. ActiveCell.Offset."

Similar presentations


Ads by Google