How To Build A Loop Within Loop In Excel VBA (Real-World VBA Task S3 P3)

How To Build A Loop Within Loop In Excel VBA (Real-World VBA Task S3 P3)



Are you ready for some advanced Excel VBA?  In this video, we take things to the next level in the real-world VBA task series by implementing a loop within a loop in Excel VBA.

Things are going to get technically complicated, so let’s first be clear about the concept here.  We need two loops because we’re looping through two sets of data.  First, we need to loop through each home team in today’s fixtures (dataset 1). Then, at the next level, we need to loop through the fixture data for each team (dataset 2).  The only way to do this in Excel VBA is to set up one loop within another – a loop within a loop.

In the session, I implement this complex setup in the VBA editor.  Frequent testing is key here – the only way to understand what is going on is to ‘step through’ the code and see at each step how VBA is working, as I do in the video.  This is why testing and debugging is a ‘metaskill’ in Excel VBA learning – it allows us to get to grips with complex structures and gradually build confidence implementing more powerful macros.  As you’ll find out, two screens can really help!

So, video 3 of the Excel VBA Real-World task series is in the books.  Let me know how you are getting on in the YouTube comments and see you in video 4!

ABOUT OUR MEMBER COMMUNITIES

Our learning communities provide exclusive Excel learning content, direct access to Chris, support and inspiration from others just like you and much, much more.  They are the best way to develop your Excel skills long-term, and to make a few friends along the way!  Check out the options below, we would LOVE to welcome you ...

ABOUT REAL-WORLD VBA TASKS SEASON 3
In the Real-World VBA Task series, we tackle a VBA challenge similar to the jobs that professionals you like are trying to automate daily using Excel VBA.

In Season 3 of the Excel VBA Real-World Task series, we explore a job I’ve been tasked with many times in my career: creating form analysis for football teams in a league table.  Form analysis the kind of thing you’ll see alongside football league tables in the newspaper or online, and it’s the perfect topic for this series for two reasons.  First, it’s a task that’s not easily done in Excel without using VBA (though it’s possible using a series of very long formulae).   Second, it requires powerful techniques such as loops, conditional statements, position control and more – so it’s broadly applicable to VBA tasks generally.  In other words, the series should help whatever VBA job you’re currently wrestling with.

In this 7-part season, I walk you through the VBA task step-by-step, from the critical planning and conceptualization phase, to application of loops, variables and more in VBA, through to combining techniques together to create a powerful ‘click-of-button’ solution.  Even I was surprised by how quickly this macro gets the job done …

It’s about more than impressing you with individual techniques such as loops in Excel VBA, however.  It’s about learning an overall approach to VBA development that you can apply in your work.  Look out for the Excel ‘Metaskills’ such as debugging that I showcase during the series – they really are the hidden gems in Excel learning.  I hope enjoy the series and do let me know in the YouTube comments how you get on.