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

Posted on July 23rd, 2015 in Chandoo.org Podcast Sessions , VBA Macros - 6 comments

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

Listen to this session

Click here to download the MP3 file.

Links & Resources mentioned in this podcast

Introduction to VBA

Using FOR Loops – Examples

Optimization & Performance of VBA code

Transcript of this session:

Download this podcast transcript [PDF]

Are FOR loops strong with your VBA code?

I personally favor FOR loops over While loops. I learned about loops in 1996 (in BASIC language). Any powerful application or program I have built ever since has its share of FOR loops. They are vital for doing awesome things with computers.

What about you? Do you use FOR loops often? When do you use them? What are your favorite implementations. Please share your tips & thoughts in the comments area.

Remember: Email me at chandoo.d@gmail.com once you finish the task mentioned in the podcast to get your FOR loops example workbook.

Written by Chandoo
Tags: , , , , , , ,
Home: Chandoo.org Main Page
? Doubt: Ask an Excel Question

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

  1. Mark says:

    I use FOR loops a lot when processing blocks of data in Excel. Sometimes it is laziness because using the FIND method to locate specific matches has effects on your application's default FIND behaviour unless you carefully restore all the default parameters like search type, direction, start point etc. after running code. A FOR loop can find data in 10,000-20,000 rows using If or Select Case within a few seconds, especially if search range is one column. In these cases the FOR condition is simply to execute from a start row number to an end number, which can be automated within VBA by locating the extent of the data using Range End properties.

  2. SOMNATH LAL says:

    IT IS REALLY VERY INTERACTIVE .

  3. V. SURESH says:

    I have used FOR LOOP a few times by borrowing/ copying and modifying the codes from other projects. STEP and EXIT FOR is new to me. Thank you for the information. The language is simple and easily understood. Thank you again and may GOD bless you good health with a bright future.

  4. Sanjay says:

    Owesom if u can share for loop

  5. Sebastian says:

    As always, the podcast is a fantastic resource for people with an interest in VBA yet not an extensive knowledge of it like me. Chandoo's clear commitment to the improvement of the skills of the listeners and his pedagogical talents are no longer a surprise but are still something I really appreciate.

    Just as for an earlier user, the use of STEP and EXIT FOR are new to me despite having used FOR loops before.

    Even for the casual user of VBA that somehow lands on this page, I fully recommend taking the type to list the podcast in its entirety as the payoff will make the time investment worth it.

  6. ashish says:

    Very Helpful. Whatever i have come across by now on this website is AWESOME. THANKS.

Leave a Reply