L06 VBA intro2 procedures.pptx - Excel Modeling VBA Intro Subs and Functions Dr Ronald K CHUNG FINA0404/3351 – Spreadsheet Modelling in Finance 2

L06 VBA intro2 procedures.pptx - Excel Modeling VBA Intro...

This preview shows page 1 - 6 out of 21 pages.

Excel Modeling: VBA Intro: Subs and Functions Dr. Ronald K. CHUNG FINA0404/3351 – Spreadsheet Modelling in Finance
Image of page 1

Subscribe to view the full document.

2 types of VBA codes VBA procedures: Sub procedure Function procedure 2 ©EQCC
Image of page 2
Sub v. Function Sub Cannot return a value Function Can return a value or object Can run as a worksheet function Won’t appear in the list of macros 3 ©EQCC
Image of page 3

Subscribe to view the full document.

To Run… to run a Sub procedure that does not require any arguments, that is, has an empty pair of parentheses after the procedure name three ways to run assigned a Shortcut key In Excel, open the Macros dialog box by pressing Alt+F8 Press the play button In VBE, put your cursor anywhere in the procedure and then press F5 4 ©EQCC
Image of page 4
Forcing Variable Declaration Include “Option Explicit” in 1 st statement in VBA module. This will make program stop and display an error message during execution if VBA encounters any variable you have not declared .
Image of page 5

Subscribe to view the full document.

Image of page 6

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes