Excel Video 426 is a practical example of nesting a loop inside another loop. Before I start, here’s a plug for MGMA’s Annual Conference in Las Vegas in October. You’ll find tons of real world examples of best practices from medical practices throughout the country. It’s a great opportunity to network, and be sure to go to my Custom Reporting session Monday afternoon. It will change the way you look at your data.
I’ll be the first to admit that my nesting loops example has nothing to do with medicine, but it is a very practical example that I hope will make nesting loops easier to understand. Watch how I create an a loop, a b loop that runs inside the a loop, and how b is reset to 1 each time the b loop gets to 20. The one line of code that’s inside both the a and the b loops ends up being run 400 times.
Finally, notice my comment out to the side of my code. The default property of Cells(a,b) is value, so Cells(a,b) is the same thing as Cells(a,b).Value. Either way works. Whatever syntax is easier for you.