Microsoft Excel workshops for business, engineering and science Innovative Microsoft Excel software design View our customer list from our over 14 years in business Phone numbers, email address and contact form Learn about EMAGENIT Home page containing upcoming Microsoft Excel classes and other EMAGENIT services Self-study Microsoft Excel manuals for business, engineering and science Microsoft Excel consulting services Microsoft Excel training schedule and prices EMAGENIT newsletter signup - Discounts Contact EMAGENIT about your questions Follow us on linked in and receive discounts up to 25% off our training upcoming Microsoft Excel classes and other EMAGENIT services
Home > Excel Resources > What is a VBA Procedure, Sub Procedure, Function Procedure?

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

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

Read about how you can repeat your Microsoft Excel workshop for free Read about our Microsoft Excel customers Read about how we won an award for our Microsoft Excel software      
 

Need Help Learning Excel VBA?

Let our Microsoft Excel VBA workshops below show you how to command Excel in ways you never thought possible. They are unlike anything taught on the training market today.

Beginning Microsoft Excel VBA - Business

Beginning Microsoft Excel VBA Workshop for Business Professionals - Outline and SignupLearn time saving Excel VBA skills that you can start to use immediately on your tough Excel problems. Drawing on our 15 years' of Excel VBA software design experience, our 2-day "hands-on" workshop shows you how to use VBA to control Excel, perform calculations, process and move data, fill out forms and tables, create charts, build dashboards, control Word and PowerPoint and much more. It provides a complete review of the VBA language. Complete Outline and Signup

Advanced Microsoft Excel VBA - Business

Advanced Microsoft Excel VBA Workshop for Business Professionals - Outline and SignupLearn how to construct advanced Excel VBA solutions that will save time, money and accomplish the seemingly impossible. Drawing on our 15 years' of Excel VBA software design experience, our 3-day "hands-on" workshop shows you how to use VBA to perform advanced analysis and data processing, command ActiveX controls and userforms, construct advanced dashboards, control databases, control Excel's advanced tools like pivot tables and control other programs. Complete Outline and Signup

Beginning Microsoft Excel VBA - Engineering & Science

Beginning Microsoft Excel VBA Workshop for Engineers and Scientists - Outline and SignupOverview: Learn how to use Excel VBA to construct engineering / science tools that reduce your tasks from days to minutes. Drawing on our award winning NASA software design experience, our 2-day "hands-on" workshop shows from an engineering & science perspective how to use VBA to control specific Excel features, process technical data, fill out forms and tables, perform sophisticated calculations, create technical charts, create custom worksheet functions for modeling, control Word and PowerPoint and much more. Taught by an engineer. Complete Outline and Signup

Advanced Microsoft Excel VBA  - Engineering & Science

Advanced Microsoft Excel VBA Workshop for Engineers and Scientists - Outline and SignupLearn to how use Excel VBA to build advanced engineering / science tools that perform complex technical tasks. Drawing on our award winning NASA software design experience, our 3-day "hands-on" workshop shows you from an engineering & science perspective how to use VBA to create advanced data analysis tools, advanced technical models, advanced database tools, dashboards using ActiveX controls and userforms and control other programs like Word and PowerPoint.  Taught by an engineer. Complete Outline and Signup

 

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.

 

Sub Procedures

  • 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.

VBA Sub Procedure

 

Function Procedures

  • 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. Note that Sub procedures can also be used to do calculations. A simple function procedure is pictured below.

VBA Function Procedure

 

What VBA Procedure to Write

  • So if you want to do a task in Excel, you write a Sub procedure, if you want to write a custom worksheet function, you write a Function procedure. Are their grey areas between the two where they can do the same thing, yes, but do not worry about them when first starting out.

 

<<What is a VBA Module and How is It Used?                How is VBA Used?>>

 

 

 

 

Site Map

Copyright © 2002-2014 EMAGENIT All Rights Reserved