Contents. Some Basics Simple VBA Procedure (Macro) To Execute The Procedure Recording A Macro About Macro Recorder VBA Objects Reference

Similar documents
Excel & Visual Basic for Applications (VBA)

BASIC EXCEL SYLLABUS Section 1: Getting Started Section 2: Working with Worksheet Section 3: Administration Section 4: Data Handling & Manipulation

MS Excel VBA Class Goals

Customizing the Excel 2013 program window. Getting started with Excel 2013

EXTENDED LEARNING MODULE M

This chapter is intended to take you through the basic steps of using the Visual Basic

EXTENDED LEARNING MODULE M

Alternatives To Custom Dialog Box

DATA 301 Introduction to Data Analytics Microsoft Excel VBA. Dr. Ramon Lawrence University of British Columbia Okanagan

Excel 2016 Advanced. Course Objectives

VISUAL BASIC 2 EDITOR

Microsoft Excel - Macros Explained

VBA Excel 2013/2016. VBA Visual Basic for Applications. Learner Guide

Excel 2016: Introduction to VBA

You can record macros to automate tedious

6/14/2010. VBA program units: Subroutines and Functions. Functions: Examples: Examples:

Introduction... 1 Part I: Getting Started with Excel VBA Programming Part II: How VBA Works with Excel... 31

MODULE VI: MORE FUNCTIONS

Macros enable you to automate almost any task that you can undertake

3. (1.0 point) To quickly switch to the Visual Basic Editor, press on your keyboard. a. Esc + F1 b. Ctrl + F7 c. Alt + F11 d.

2. create the workbook file

Excel Programming with VBA (Macro Programming) 24 hours Getting Started

Macros enable you to automate almost any task that you can undertake

Create an external reference (link) to a cell range in another workbook

Download the files from you will use these files to finish the following exercises.

Introduction to macros

Visual Basic for Excel 97/2000/XP

MICROSOFT EXCEL 2000 LEVEL 5 VBA PROGRAMMING INTRODUCTION

Work more efficiently by learning how to automate recurring tasks and create user applications

Workbooks (File) and Worksheet Handling

Appendix III. Installing the Microsoft Excel Add-in For the Freeway Service Patrol Beat Evaluation Model

Corporate essentials

Read Me First (Excel 2007)

Microsoft Office Illustrated. Getting Started with Excel 2007

Computer Applications Data Processing FA 14

Microsoft Excel 2010 Level 1

Unit 9 Spreadsheet development. Create a user form

Using Custom Number Formats

Microsoft Excel 2013 Unit 1: Spreadsheet Basics & Navigation Student Packet

Microsoft MOS-EXP. Microsoft Excel 2002 Core.

The clean-up functionality takes care of the following problems that have been happening:

Read More: Index Function Excel [Examples, Make Dynamic Range, INDEX MATCH]

Do Until Loop in Excel VBA with Examples

Microsoft Excel 2016 Level 1

TIPS & TRICKS SERIES

EXAM Microsoft Excel 2010 Expert. Buy Full Product.

Microsoft Office Excel 2007: Basic Course 01 - Getting Started

Candy is Dandy Project (Project #12)

Microsoft Excel 2007 Macros and VBA

PHLI Instruction (734) Introduction. Lists.

Module 1 - Applied Named Formulas: Invoice 2-1

Chart Wizard: Step 1 (Chart Types)

Mathews Malnar and Bailey, Inc.

Macros in Excel: Recording, Running, and Editing

Advance Excel Performing calculations on data 1. Naming groups of data 2. Creating formulas to calculate values

M i c r o s o f t E x c e l A d v a n c e d. Microsoft Excel 2010 Advanced

Reference Services Division Presents. Excel Introductory Course

Creating Visual Basic Macros that Use Microsoft Excel Solver

Chapter 4. Microsoft Excel

ADVANCED EXCEL Course Modules for Advance Excel Training Online (MS Excel 2013 Course):

download instant at

Excel 2013 Power Programming with VBA

Intermediate Microsoft Excel 2010 Tables and Printing

Explore commands on the ribbon Each ribbon tab has groups, and each group has a set of related commands.

Introduction. Saving Workbooks. Excel 2010 Saving. To Use the Save As Command: Page 1

Troubleshooting in Microsoft Excel 2002

Acknowledgements About the Author Starting off on the Right Foot p. 1 Basic Terminology p. 2 Title Bar p. 3 Menu Bar p. 3 Active Cell p.

Rev Up to Excel 2010

<excelunusual.com> Creating, Sizing, Translating and Rotating 2D Shapes in Excel by George Lungu. < 1

COURSE CONTENT Excel with VBA Training

5. Excel Fundamentals

Outline. Debugging. In Class Exercise Solution. Review If Else If. Immediate Program Errors. Function Test Example

CS 200. Lecture 07. Excel Scripting. Miscellaneous Notes

Microsoft Excel Expert 2010, Objective Domain

Consolidate and Summarizing Data from Multiple Worksheets

1 MAPLE EXCEL MACRO TECH NOTE JOEL HYING

Assessed Exercise 1 Working with ranges

DOWNLOAD PDF VBA MACRO TO PRINT MULTIPLE EXCEL SHEETS TO ONE

Getting started 7. Writing macros 23

As you probably know, Microsoft Excel is an

BEST PRACTICES SAGE MAS INTELLIGENCE REPORT WRITING

Financial Management System

Excel Level Three. You can also go the Format, Column, Width menu to enter the new width of the column.

CS 200. Lecture 07. Excel Scripting. Excel Scripting. CS 200 Fall 2016

CS 200. Lecture 07. Excel Scripting. Miscellaneous Notes

Creating Automated Dashboard Excel 2013 Contents

Creating and Using an Excel Table

If you re anxious to jump into VBA programming, hold your horses. This

Delivering training since 1996

The Microsoft Excel Course is divided into 4 levels

1. Position your mouse over the column line in the column heading so that the white cross becomes a double arrow.

Excel Tip: How to create a pivot table that updates automatically

Empower and invest in yourself WORKBOOK MICROSOFT EXCEL INTERMEDIATE

Create a Relationship to build a Pivot Table

UW Department of Chemistry Lab Lectures Online

EXCEL WORKSHOP III INTRODUCTION TO MACROS AND VBA PROGRAMMING

Integrating Microsoft Office Learn about object linking and embedding (OLE) Tutorial 1 Integrating Word and Excel

Excel window. This will open the Tools menu. Select. from this list, Figure 3. This will launch a window that

Excel Macro Record and VBA Editor. Presented by Wayne Wilmeth

Editing XML Data in Microsoft Office Word 2003

Transcription:

Introduction To VBA

Contents Some Basics Simple VBA Procedure (Macro) To Execute The Procedure Recording A Macro About Macro Recorder VBA Objects Reference

Some Basics Code: You perform actions in VBA by executing VBA code. You write (or record) VBA code, which is stored in a VBA module. Module: VBA modules are stored in an Excel workbook file, but you view or edit a module by using the Visual Basic Editor (VBE). A VBA module consists of procedures. Procedures: A procedure is basically a unit of computer code that performs some action. VBA supports two types of procedures: Sub procedures and Function procedures. 1. Sub: A Sub procedure consists of a series of statements and can be executed in a number of ways. 2. Function: A VBA module can also have Function procedures. A Function procedure returns a single value (or possibly an array). A Function can be called from another VBA procedure or used in a worksheet formula. Objects: VBA manipulates objects contained in its host application. (In this case, Excel is the host application.) Excel provides you with more than 100 classes of objects to manipulate. Collections: Like objects form a collection. Object hierarchy:when you refer to a contained or member object, you specify its position in the object hierarchy by using a period (also known as a dot) as a separator between the container and the member. Active objects: If you omit a specific reference to an object, Excel uses the active objects.

Some Basics (Contd ) Objects properties: Objects have properties. A property can be thought of as a setting for an object. VBA variables: You can assign values to VBA variables. Object methods: Objects have methods. A method is an action that is performed with the object. Standard programming constructs: VBA also includes many constructs found in modern programming languages, including arrays, loops, and so on. Events: Some objects recognize specific events, and you can write VBA code that is executed when the event occurs.

Simple VBA Procedure (Macro) Sub SayHello() Msg = Is your name & Application.UserName &? Ans = MsgBox(Msg, vbyesno) If Ans = vbno Then MsgBox Oh, never mind. Else MsgBox I must be Clairvoyant! End If End Sub

To Execute The Procedure Press F5. Choose Run Run Sub/UserForm. Click the Run Sub/UserForm button on the Standard toolbar.

Recording A Macro Macro Recorder is a tool that converts your Excel actions into VBA code. 1. Activate a worksheet in the workbook (any worksheet will do). 2. Choose Developer Code Record Macro (Excel displays its Record Macro dialog box). 3. Click OK to accept the default setting for the macro (Excel automatically inserts a new VBA module into the workbook s VBA project. From this point on, Excel converts your actions into VBA code. Notice that Excel s status bar displays a blue square. You can click that control to stop recording). 4. Choose PageLayout Page Setup Orientation Landscape. 5. Select Developer Code Stop Recording (or click the blue square in the status bar). Excel stops recording your actions.

About Macro Recorder The macro recorder is appropriate only for simple macros or for recording a small part of a more complex macro. Not all the actions you make in Excel get recorded. The macro recorder can t generate code that performs looping (that is, repeating statements), assigns variables, executes statements conditionally, displays dialog boxes, and so on. The macro recorder always creates Sub procedures. You can t create a Function procedure by using the macro recorder. The code that is generated depends on certain settings that you specify. You ll often want to clean up the recorded code to remove extraneous commands.

VBA Objects Objects have unique properties and methods. You can manipulate objects without selecting them. Properties can return a reference to another object. You can refer to the same object in many different ways.

Reference Excel 2010 Power Programming with VBA by John Walkenbach.

THANK YOU