Putting It All Together – Our First VBA Application [Part 4 of 5 – Excel VBA Crash Course]

Share

Facebook
Twitter
LinkedIn

This article is part of our VBA Crash Course. Please read the rest of the articles in this series by clicking below links.

What are Variables, Conditions & Loops are and how to use them in Excel VBA

  1. What is VBA & Writing your First VBA Macro in Excel
  2. Understanding Variables, Conditions & Loops in VBA
  3. Using Cells, Ranges & Other Objects in your Macros
  4. Putting it all together – Your First VBA Application using Excel
  5. My Top 10 Tips for Mastering VBA & Excel Macros

In part 4 of our VBA Crash Course, we are going to create our very first VBA application using what we learned so far.

Our first Application – What is it supposed to do anyway?

Remember the “We Are Nuts” example. We are back to it. This time, we will create a daily sales tracker application that makes your job a breeze. But saying words like breeze when defining your next VBA application is a dangerous thing. So lets list down all the things our little Excel VBA workbook should do.
Sample Excel VBA Application - Demo - Excel VBA Crash Course

  1. The current method of using Inputboxes to capture 24 sale values and any reasons for deviation is tedious. So our application should instead process the values from already entered values and ask for reasons (thru inputbox) only when the sales are too low or too high.
  2. At the end of processing the sales, we want to see a short summary of how we did for the day. Something like this,
    Summary Statistics shown in our application - Excel VBA Crash Course
  3. Once we finish viewing the statistics a snapshot of the daily sales & along with summary statistics should be saved to current folder as PDF for later reference.

Designing our first VBA Application – Key Ingredients:

In this section, let us understand how our application should be designed and what goes in to it.

First, let us look at various things our application need to do, in a schematic. This types of diagrams are called as flow charts.

Flow Chart for Our VBA Application - VBA Crash Course

Key Ingredients of our Daily Sales Tracker Application:

Lets look at each area of our application and understand what VBA technique or statement helps us to do it.

  • Process one store sale at a time: This is achieved with the FOR EACH statement [Related: What are VBA loops?]
  • Capture reasons for deviation: Lets do InputBox() for this
  • Calculate Summaries as we go: Some variables to calculate the summaries as we go. And a few IIF() formulas to help us update the values where needed. (PS: IIF is Inline IF Formula)
  • Display Summary Statistics: We will use MessageBox() for this.
  • Save a snapshot of the report: This is done by Range.ExportAsFixedFormat() method. [Related: understanding cells, ranges & other VBA objects]

Demo of our Daily Sales Tracker VBA Application

Here is a quick demo of our Daily Sales Tracker Application


Download our Daily Sales Tracker VBA Workbook:

Click here to download the Daily Sales Tracker VBA Workbook. Enable macros, enter some values and play with it.

If you just want to examine code, see this page.

What Next – My top 10 tips for using VBA

In final part of our VBA crash course, Learn my top 10 tips for mastering VBA.

If you have not read, please read the first 3 parts of this series,

  1. Introduction to Excel VBA – What is it & How to write your first VBA Macro.
  2. Understanding Variables, Conditions & Loops in VBA
  3. What are Excel VBA Objects and how to use them?

How do you like this VBA Application? How would you enhance it?

This application is one simple example of what you can do with VBA. Learning how to use Excel & VBA can enable you do several more awesome things at your work & life.

Do you like this application? How would you have designed it? Please share your ideas & tips using comments.

Join Our VBA Classes

We run an online VBA (Macros) Class to make you awesome. This class offers 20+ hours of video content on all aspects of VBA – right from basics to advanced stuff. You can watch the lessons anytime and learn at your own pace. Each lesson offers a download workbook with sample code. If you are interested to learn VBA and become a master in it, please consider joining this course.

Click here to learn more and Join our VBA program.

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

Leave a Reply