What is a VBA Procedure, Sub Procedure, Function Procedure?

What is a VBA Procedure, Sub Procedure, Function Procedure?

Microsoft Excel VBA Tutorial

A VBA procedure is the main building block of your Excel VBA programs you will develop.

What is a VBA Procedure?

  • The word Macro is slang for the word VBA procedure. It is a throw back to pre 1994 Microsoft Excel
  • A procedure is defined as a named group of statements that are run as a unit
    • A statement is simply 1 complete line of code
  • VBA procedures are used to perform tasks such as controlling Excel’s environment, communicating with databases, calculating equations, analyzing worksheet data, creating charts…etc
  • A VBA procedure unit or block consists of a procedure statement (Sub or Function) and an ending statement with statements in between
  • A VBA procedure is constructed from three types of statements: executable, declaration and assignment statements. The statements between a procedure’s declaration and ending statement (i.e. Sub and End Sub) perform the procedure's task; what you are trying do.
    • For example, the Sub procedure pictured below commands Excel's Sort feature on the active worksheet when it is run
  • Procedures are typed and stored in a Module
  • Procedures are executed or run in order to carry out their statements. When a procedure is run, its statements (i.e. lines) are executed in a top-down line by line fashion performing operations. Think of reading a book page. Note that typing a procedure in a module does not run it. You must do this after typing it by variety of different methods. Until you run it, it is just basically text sitting in a document.
  • VBA has two basic types of procedures that you can create: Sub procedures and Function procedures

What is a Sub Procedure?

  • Sub procedures are written when you want to command Excel like creating a chart, analyzing data, coloring cells, copying and pasting data...etc. A simple Sub procedure is pictured below.
What is a Sub Procedure?

Sub Procedure (Click to Enlarge)

What is a VBA Function Procedure?

  • Function procedures are created when you want to make your own custom worksheet functions or perform a calculation that will be used over and over again in your computer code. Note that Sub procedures can also be used to do calculations. A simple function procedure is pictured below.
What is a VBA Function Procedure?

Function Procedure (Click to Enlarge)

We Can Teach These Skills to You - Our Microsoft Excel VBA Training

Beginning Microsoft Excel VBA Training for Business

Beginning Excel VBA Training for Business Professionals

Our 2-day "hands-on" beginning Microsoft Excel VBA training shows you the essential Excel VBA programming skills that you need to immediately develop useful powerful data processing and analytical tools that your business needs now. View Outline

Advanced Microsoft Excel VBA Training for Business

Advanced Excel VBA Training for Business Professionals

Our 3-day "hands-on" advanced Microsoft Excel VBA training shows you how to build advanced data processing tools, analysis tools and dashboard displays using Microsoft Excel VBA that will solve the most difficult business tasks. View Outline

Beginning Microsoft Excel VBA Training for Engineers and Scientists

Beginning Excel VBA Training for Engineers and Scientists

Our 2-day "hands-on" beginning Microsoft Excel VBA training shows you how to use Excel VBA to control key Excel engineering and science features, format and process technical data, perform sophisticated calculations, create technical charts, create custom worksheet functions, manage large models and data, create report tools and much more. Taught by an engineer. View Outline

Advanced Microsoft Excel VBA Training for Engineers and Scientists

Advanced Excel VBA Training for Engineers and Scientists

Our 3-day "hands-on" advanced Microsoft Excel VBA training shows you how to use Excel VBA to build advanced engineering and science tools that that solve your most difficult data and analysis tasks and help you visualize your data sophisticated interfaces. Taught by an engineer. View Outline



Site Map

Copyright © 2002-2015

EMAGENIT All Rights Reserved