All articles with 'for each' Tag

CP039: May the FOR Loop be with you – Introduction to For Loops in Excel VBA

Published on Jul 23, 2015 in Chandoo.org Podcast Sessions, VBA Macros

In the 39th session of Chandoo.org podcast, Let’s learn about FOR loops.

There is a special giveaway in this podcast. It is a workbook with several FOR loop VBA code examples. Listen to the episode for instructions.

Introduction to Excel VBA FOR Loops - What are they, how to use them - Chandoo.org Podcast - Session 039

What is in this session?

In this podcast,

  • Announcements
  • What is a loop – plain English & technical definitions
  • For Loop vs. other kind of loops (While & Until)
  • For Next loops
  • For Each loops
  • Nested For loops
  • Special tips on For loops
  • Performance issues & infinite loops
  • Conclusions & giveaway
Continue »

Split an Excel File in to Many using VBA [Videos]

Published on Oct 19, 2011 in VBA Macros
Split an Excel File in to Many using VBA [Videos]

Splitting an Excel file in to many is easier than splitting bill in a restaurant among friends. All you need is advanced filters, a few lines of VBA code and some data. You can go splitting in no time.

Context:

Lets say you have lots of data like this in a file. And you want to split this in to multiple files, one per salesperson.

Solution – Split Data in to Multiple Files using Advanced Filters & VBA

The process of splitting data can be broken down to 4 steps …,

Continue »

Understanding Variables, Conditions & Loops in VBA [Part 2 of 5]

Published on Aug 30, 2011 in VBA Macros
Understanding Variables, Conditions & Loops in VBA [Part 2 of 5]

In part 2 of our VBA Crash Course, we are going to learn what Variables, Conditions & Loops are and how to use them in Excel VBA.

What are Variables, Conditions & Loops?

If you are new to computer programming, you might think I am speaking legalese. So, to make it easy to understand, lets assume you run a bunch of stores across the town. To make it colorful, lets call your stores “We are nuts” – a dry fruit and nuts store chain. At the end of every day, you call each of the 24 store managers and ask them how much sales they have made in that day.

Now, you are not the kind of boss who micro-manages & nitpicks. So you don’t really note down sale for every store. Instead, as you call the store manager, you just mentally update the total. So first store says “$2,300” your total is 2300. Second manger says “$4,000”, the total now will be 6300. So on.

The value 6300 here is nothing but a variable.

We will use the “We are nuts” example thru out this lesson & towards the end we will build a sales logging application using Excel VBA.

Continue »