HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

How to Use Excel VBA Code - Real Example P3

5,789 views October 25, 2019 9:55

Watch on YouTube
ChannelTiger Spreadsheet Solutions

Description from the creator

How can we use Excel VBA code to speed up manual work in Excel? In this series we explore an example Excel VBA project sent in by Eric, a viewer of the channel. We aim to build an Excel VBA application to move data around a file at the 'click-of-a-button', saving hours of frustrating manual work. The application should be flexible and scaleable enough to handle changes in business circumstances - a challenge indeed! Let's get into it...

Download File Link:
tinyurl.com/y4d6ds62
----------------------------------------------------------------
In the third video, we first implement a 'loop within a loop' - the powerful mechanism that allows us to get the first part of this job done. Conceptual thinking always comes first, so what exactly are we trying to do, and can we explain it clearly in normal language? Let's try...

We already have one loop set up which loops through the worksheets in the file. The next loop, which operates 'one level down' and is embedded within the first, will loop through the name cells on each sheet. With the conceptual understanding clear, we can move onto the programming.

Chris uses a 'for each object in the collection' / 'for - each' loop to work through the name cells on each sheet. This type of loop could be applied to open workbooks, shapes on a sheet, sheets in a file, or another of Excel's 'collections' of objects. It shows how, if we can navigate Excel's object hierarchy, we can make coding easier.

In this case we loop through each cell in the range of cells that contains customer names, as defined by the dynamic range reference we created in the previous video. We test the mechanism using message boxes to extract information from the VBA editor during code execution. Job done - next!

The next step is to understand if a particular name appears in the list of names we are assembling. Remember, Eric has requested a list of 'unique' names, so names must not be duplicated. So, how can we check if a name already appears in the list? We set up a thing of beauty: worksheet formulae working together with Excel VBA to get a job done. In this case we create a 'COUNTIF' formula to establish if a value appears in a range; if the formula returns a value of zero, we know the name needs to be added to the list.

Onwards!

See you in part 4. Don't forget to let us know in the comments how you get on, Chris will get back to you.

Series Playlist Link:
tinyurl.com/y4pmrkxn

🎁YOUR EXCEL CHEATSHEET
🎁1 Page Summary Of What You Need To Know
tinyurl.com/yc7jlmbs

facebook.com/TigerSpreadsheetSolutions
twitter.com/TigSpreadsheets

Also on Insta :-)

About this tutorial

Tiger Spreadsheet Solutions published this 9:55 video tutorial on October 25, 2019. It has been watched 5,789 times on YouTube.

Category
Education
Duration
9:55
Published
October 25, 2019
Views
5,789
Likes
86

Tags

Share

Further reading

  • Getting started with VBA in Office | Microsoft Docs docs.microsoft.com

    The VBA code in this article runs against an open Office application where many of the objects that the code manipulates are already up and running; for example, the Application itself, the Worksheet in Excel, the Docum…

  • VBA Code Examples for Excel - Automate Excel automateexcel.com

    To write VBA code in Excel open up the VBA Editor (ALT + F11). Type "Sub HelloWorld", Press Enter, and you've created a Macro! OR Copy and paste one of the procedures listed on this page into the code window.

  • VBA Examples | List of Top 19 Excel VBA Examples for Beginners wallstreetmojo.com

    Excel VBA Examples for Beginners. Macros are your best friend when it comes to increase your productivity or save some time at your workplace. Right from small tasks to big tasks, we can automate by using the VBA coding…

This tutorial in other languages