40
MS Excel - Macros EL Abquina Tech Ops PH www.techopsph.com

Microsoft Excel - Macros

Embed Size (px)

Citation preview

Page 1: Microsoft Excel - Macros

MS Excel - Macros

EL AbquinaTech Ops PHwww.techopsph.com

Page 2: Microsoft Excel - Macros

This is not a programming class (but

we will teach a bit of code)

Page 3: Microsoft Excel - Macros

INTRODUCTION

If you want to eliminate repetitious command sequence or data manipulation tasks, MACROS will help as it is the automation capability of MS Excel.

A single instruction that expands automatically into a set of instructions.In computer science; it is described as a RULE or PATTERN

MACROS

Page 4: Microsoft Excel - Macros

Be familiar with features like:

• Create Macros by Recording• Expand macros for multiple tasks• Making macros available to all workbooks• Launch Macros by Keystroke or Toolbar• Learn VBA environment and edit code• Debug and Testing via Step-mode or split

screens• Do Loops and If commands

Page 5: Microsoft Excel - Macros

GETTING STARTED

• Let us know when it is appropriate to use macros

• Prepare our exercise files

Page 6: Microsoft Excel - Macros

Let us make sure you have MACROS in your

computer

Page 7: Microsoft Excel - Macros

The idea of MACROS

• Any sequences of actions can be turned into a MACRO.

• Record and Store that, so can be used in the future by doing a single click or action

• WHy Macros?

• To automate your work, and save you precious time!

Page 8: Microsoft Excel - Macros

Macro Example

• Open Exercises

Page 9: Microsoft Excel - Macros

Before starting…Security Concerns

• Security issues about macro usage;– File extension is .xlsx– Macro enabled files are .xlsm

Page 10: Microsoft Excel - Macros
Page 11: Microsoft Excel - Macros

• File > Options > Trust Center > Trust Center Settings…

• Go To Trusted Locations

Page 12: Microsoft Excel - Macros

RECORDING A MACRO

Option1: In the status bar (beside “Ready”).– Right click and check Macro Recording

Option2: Under VIEW Tab, there is a MACROS button, then Record Macro…

Page 13: Microsoft Excel - Macros

RECORDING A MACRO

• Choose A Macro Name• Make a Short-Cut Key• Store Macro in– This Workbook– New Workbook– PERSONAL Workbook

• Description

Page 14: Microsoft Excel - Macros

RECORDING A MACRO - Watchout

• Almost ANYTHING you do can be recording (even scrolling, clicking cells,) except for CANCEL, etc./

• After testing/running a macro, we cannot UNDO the actions– Stay away from DELETE data

Page 15: Microsoft Excel - Macros

RECORDING A MACRO - VBA• When you create a MACRO, you create a “small program”• Under Macros > View Macros– The small program in the language called VBA or VISUAL

BASIC for APPLICATIONS

Page 16: Microsoft Excel - Macros

• The more you do recording, you will get to learn about

• Later we will learn about simple codes, Function and Module

Page 17: Microsoft Excel - Macros

RUNNING A MACRO

• Here we will discuss how to Execute, Play Back, etc.

• There are 3 ways to run a Macro– Keystroke– Toolbar– Object

Page 18: Microsoft Excel - Macros

MACROS Tool

• Under VIEW Tab > Macros

Page 19: Microsoft Excel - Macros

KEYSTROKE

Page 20: Microsoft Excel - Macros
Page 21: Microsoft Excel - Macros

KEYSTROKE

Page 22: Microsoft Excel - Macros

PLAYBACK RIBBON

• You can add a button in the QUICK ACCESS TOOLBAR (Excel 2007/2010)

Page 23: Microsoft Excel - Macros

PERSONAL MACRO WORKBOOK

• This is a repository of MACROS you create that can be ran on ALL WORKBOOS that you might open.

Page 24: Microsoft Excel - Macros

USING VBA

• Visual Basic For Applications– Read code: Select Macro then EDIT– Press F11

Page 25: Microsoft Excel - Macros
Page 26: Microsoft Excel - Macros

USING VBA - Components

Page 27: Microsoft Excel - Macros

RECORDING A MACRO IN STAGES

• Knowing the stages of recording will make you familiar if you should need to do any change.

Page 28: Microsoft Excel - Macros

TIP

• Whenever you record, always look for the code by pressing F11

• This will get you familiar on how you make some alterations

Page 29: Microsoft Excel - Macros

2ND SESSION

Page 30: Microsoft Excel - Macros

CREATING NON RECORDED VBA CODE

• ABSOLUTE and RELATIVE• FOR LOOP• DO LOOP• INTERACTIVE

Page 31: Microsoft Excel - Macros

ABSOLUTE and RELATIVE

• Macros are recorded that relative to the initial selected cell in the worksheet

Page 32: Microsoft Excel - Macros

The concept of repetition is within

macros.

Page 33: Microsoft Excel - Macros

FOR LOOP• The concept of repetition is

enabled using macros.

Page 34: Microsoft Excel - Macros

DO LOOP• DO WHILE or DO UNTIL

Page 35: Microsoft Excel - Macros

INTERACTIVE

• A macro that pauses and asks for input from the user

Page 36: Microsoft Excel - Macros

Macro Project – Converting a Mailing List into a Database List

• Scoping• Partial• Testing – Press F8• Together• Joining• Stream-lining

Page 37: Microsoft Excel - Macros

PERSONAL MACRO WORKBOOK – ADVANCED

Page 38: Microsoft Excel - Macros

Conclusion

Page 39: Microsoft Excel - Macros

Assignment

Page 40: Microsoft Excel - Macros

Thank You