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.
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
Podcast: Play in new window | Download
Subscribe: Apple Podcasts | Spotify | RSS
Click here to download the MP3 file.
Links & Resources mentioned in this podcast
Introduction to VBA
- Introduction to Excel VBA – 5 part crash course
- Introduction to VBA – what is it and how to get started – Podcast #22
Using FOR Loops – Examples
- Looking up when data wont play nice – Using FOR Loops
- Understanding variables, conditions & loops in VBA
- Split an Excel file in to many using For Each loop
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.
7 Responses to “CP039: May the FOR Loop be with you – Introduction to For Loops in Excel VBA”
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.
IT IS REALLY VERY INTERACTIVE .
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.
Owesom if u can share for loop
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.
Very Helpful. Whatever i have come across by now on this website is AWESOME. THANKS.
Great journey through FOR loops in VBA. Need to learn more of VBA from you.