MENU

Fun & Interesting

VBA For Loop - A Complete Guide

Excel Macro Mastery 88,336 4 years ago
Video Not Working? Fix It Now

? Ready to master VBA? - Check out my full courses: https://courses.excelmacromastery.com/ - Subscribe to the channel here: https://bit.ly/36hpTCY -Want to download the source code for this video? Go here https://bit.ly/3CKyRIA (Note: If the download page doesn't work then make sure to turn off any popup blockers) VBA For Loop - A Complete Guide In this video I will show you how to use the For Loop in VBA. The For Loop is an extremely powerful part of VBA programming and it is very important to understand it. Make sure to download the source code below which has 20 examples of using For Loops with ranges, arrays, the dictionary and more. #VBAFORLOOP #VBALOOP #EXCELVBAFOR Useful VBA Shortcut Keys ======================== Debugging: Compile the code: Alt + D + C OR Alt + D + Enter Run the code from the current sub: F5 Step into the code line by line: F8 Add a breakpoint to pause the code: F9(or click left margin) Windows: View the Immediate Window: Ctrl + G View the Watch Window: Alt + V + H View the Properties Window: F4 Switch between Excel and the VBA Editor: Alt + F11 View the Project Explorer Window: Ctrl + R Writing Code: Search keyword under cursor: Ctrl + F3 Search the word last searched for: F3 Auto complete word: Ctrl + Space Get the definition of the item under the cursor: Shift + F2 Go to the last cursor position: Ctrl + Shift + F2 Get the current region on a worksheet: Ctrl + Shift + 8(or Ctrl + *) To move lines of code to the right(Indent): Tab To move lines of code to the left(Outdent): Shift + Tab Delete a Line: Ctrl + Y(note: this clears the clipboard) Table of Contents: 00:00 - Introduction 00:27 - Why do we need the For Loop? 02:35 - How to Create a For Loop 03:51 - How the For Loop works 07:57 - Exiting the For Loop 08:44 - Using a For Loop to read a Collection 10:02 - Using a For Loop to read a 1D Array 11:11 - Using a For Loop to read a 2D Array

Comment