Excel Macro Mastery – How You Can Write VBA Like a Professional in 15 Simple Steps by Paul Kelly
Author:Paul Kelly [Kelly, Paul]
Language: eng
Format: azw3
Published: 2014-11-24T16:00:00+00:00
‘ Same as above except condition evaluates at the end
iRow = 1
Do
ThisWorkbook.Worksheets("Sheet1").Cells(iRow, 1) = iRow
iRow = iRow + 1
Loop While ThisWorkbook.Worksheets("Sheet1").Cells(iRow, 1) <> “”
End Sub
The two loops in the example are the same except for the placement of the While Condition. The difference between them is subtle. The second one will run at least once.
Notice that you have to maintain your own count here by adding 1 to iRow each time. Make sure your condition will eventually turn false or you will end up with an Infinite Loop (If this happens then use Ctrl Break to exit).
Notice also these loops are exactly the same as the For Loop example with the Exit For. The reality is that you can use a For Loop for almost everything you do in VBA. This is because most of what you do in VBA requires reading through cells and For Loops are best suited for this. The other loops are useful to know because you will see them in legacy code.
In other languages While loops are very useful. In VBA you tend to use loops with cells or sheet which is why the For Loop is so dominant.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Salesforce Advanced Administrator Certification Guide by Enrico Murru(1447)
Microsoft Power Platform Functional Consultant: PL-200 Exam Guide by Julian Sharp(1257)
Implementing Microsoft SharePoint 2019 by Lewin Wanzer and Angel Wood(1225)
Office 365 User Guide by Nikkia Carter(1160)
Scrivener for Dummies by Gwen Hernandez(564)
Advanced Excel Success by Alan Murray(541)
Automated Data Analysis Using Excel by Bissett Brian D.;(537)
Personal Finance in Your 20s & 30s For Dummies by Eric Tyson(513)
EXCEL 2021: Learn Excel Essentials Skill with Practical Exercises for Dummies by STRATVERT KEVIN(493)
Excel Dashboards and Reports for Dummies by Michael Alexander(484)
Excel 2019 All-In-One for Dummies by Harvey Greg;(478)
Basic SPSS Tutorial by Manfred te Grotenhuis & Anneke Matthijssen(470)
Tableau Desktop 10: Get up and running in a blaze with visual modular examples! by Jaxily(466)
Excel Bible for Beginners: Excel for Dummies Book Containing the Most Awesome Ready to use Excel VBA Macros by Suman Harjit(457)
Dashboarding and Reporting with Power Pivot and Excel: How to Design and Create a Financial Dashboard with PowerPivot  End to End by Kasper de Jonge(451)
Dashboarding and Reporting with Power Pivot and Excel by de Jonge Kasper(449)
Microsoft Office Access 2007 Step by Step by Steve Lambert & M. Lambert & Joan Lambert(447)
Excel 2007 Dashboards & Reports For Dummies by Michael Alexander(403)
Excel Bible for Beginners: Excel for Dummies Guide to the Best Excel Tools, Tips and Shortcuts you Must Know by Suman Harjit(401)
