Preview

Vba Introduction

Better Essays
Open Document
Open Document
10854 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Vba Introduction
An Introduction to VBA in Excel
Robert L. McDonald† First draft: November, 1995 November 3, 2000



Abstract This is a tutorial showing how to use the macro facility in Microsoft Office—Visual Basic for Applications—to simplify analytical tasks in Excel.

Contents
1 Introduction 2 Calculations without VBA 3 How to Learn VBA 4 Calculations with VBA 4.1 Creating a simple function . . . . . . . . . . . . 4.2 A Simple Example of a Subroutine . . . . . . . 4.3 Creating a Button to Invoke a Subroutine . . . 4.4 Functions can call functions . . . . . . . . . . . 4.5 Illegal Function Names . . . . . . . . . . . . . . 4.6 Differences Between Functions and Subroutines 3 3 4 5 5 7 7 8 9 9

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

∗ Copyright c 1995-2000 Robert L. McDonald. Thanks to Jim Dana for asking stimulating questions about VBA. † Finance Dept, Kellogg School, Northwestern University, 2001 Sheridan Rd., Evanston, IL 60208, tel: 847-491-8344, fax: 847-491-5719, E-mail: r-mcdonald@northwestern.edu.

CONTENTS

2

5 Storing and Retrieving Variables in a Worksheet 5.1 Using a named range to read and write numbers from spreadsheet . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 Reading and Writing to Cells Which are not Named. . . 5.3 Using the “Cells” Function to Read and Write to Cells.

10 the . . . . . . . . . 11 12 13

6 Using Excel Functions 13 6.1 Using VBA to compute the Black-Scholes formula . . . . . . 13 6.2 The Object Browser . . . . . . . . . . . . . . . . . . . . . . . 15 7 Checking for Conditions 16

8 Arrays 17 8.1 Defining Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . 18 9 Iterating 19 9.1 A simple for loop . . . . . . . . . . . . . . . . . . . . . . . . . 20 9.2 Creating a binomial tree . . . . . . . . . . . . . . . . . . . . . 20 9.3 Other kinds of loops . . . . . . . . . . . . . . . . . . . . . . . 22 10 Reading and Writing Arrays 10.1

You May Also Find These Documents Helpful

  • Satisfactory Essays

    Bsbwor501 Final Exam

    • 397 Words
    • 2 Pages

    (TCO 1) Which of the following describes the function of the Formula Bar (as it applies to Excel…

    • 397 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Attach supporting Microsoft® Excel® tables and graphs to your paper. Spreadsheets must detail all calculations.…

    • 467 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    The aim of this guide is to teach you the basics of using a range of formulas in Microsoft Office Excel; this guide covers the following formulas: Addition; Subtraction, Multiplication, Division, Average & Percentage.…

    • 2823 Words
    • 12 Pages
    Good Essays
  • Good Essays

    In this project, you will create a named range and use it to set data validation. You will use a PMT function to calculate a value and then use it in a two-variable data table. You will also enter VLOOKUP functions to return values from a table, and format cells in the workbook. You will also audit a worksheet and correct errors.…

    • 566 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    404 Lesson 2

    • 336 Words
    • 4 Pages

    Directions: Each question of this assignment should be prepared as a separate sheet in one Excel file. Please change the sheet names at the bottom of the page to the question number. Then, follow the directions for each question below. Be sure to show your calculations and label your work for full credit. This assignment is worth 50 points. The grading rubric may be previewed in the Cost Behavior Drop Box.…

    • 336 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Unit 42 M3

    • 430 Words
    • 2 Pages

    Within the Excel spreadsheet program one can create buttons that can operate certain tasks such as a button to go to the next record or a button to calculate the attendance percentage. These buttons are programmable according to the user needs. Such small command operations are known as Active X control. The speciality of Active X controls are that they are designed to work over the internet through web browsers such as internet explorer. ActiveX is not a programming language, but rather a set of rules for how applications should share information.…

    • 430 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Ss2 Assesment

    • 1737 Words
    • 7 Pages

    2.2 Select and use a range of appropriate functions and formulas to meet calculation requirements…

    • 1737 Words
    • 7 Pages
    Powerful Essays
  • Powerful Essays

    SS2 Assessment

    • 2272 Words
    • 11 Pages

    2.2 Select and use a range of appropriate functions and formulas to meet calculation requirements…

    • 2272 Words
    • 11 Pages
    Powerful Essays
  • Satisfactory Essays

    4. You plan to use the Fill Down feature on a formula and you need to keep a cell reference the same.…

    • 985 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    • Maintain standard formatting of numbers throughout your model • Maintain standard formatting of worksheets throughout your model • Maintain standard column and row headings across multiple sheets…

    • 2666 Words
    • 11 Pages
    Powerful Essays
  • Powerful Essays

    Ross, Stephen. Westerfield, Randolph. And Jordan, Bradford. Essentials of Corporate Finance. Eighth Edition Irwin, 1996…

    • 1163 Words
    • 5 Pages
    Powerful Essays
  • Powerful Essays

    Microsoft Excel

    • 1757 Words
    • 8 Pages

    7. On the File menu, click Close and Return to Microsoft Excel when you finish writing the macro.…

    • 1757 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Protac

    • 827 Words
    • 4 Pages

    1. 2. 3. 4. 5. Solver y programación lineal El modelo Optimización Informes en excel Ejercicios…

    • 827 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Business statistics

    • 2098 Words
    • 8 Pages

    Your assignment must be presented in Microsoft (MS) Word. Copy and paste any relevant Excel outputs to this document immediately before any relevant written answers to each task.…

    • 2098 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Employment and Question

    • 289 Words
    • 2 Pages

    2. Construct an appropriate excel sheet (With all related Columns Specified) for First 2 Questions.…

    • 289 Words
    • 2 Pages
    Satisfactory Essays

Related Topics