excelvbaloopsexcel-2003

Loop through each row of a range in Excel


This is one of those things that I'm sure there's a built-in function for (and I may well have been told it in the past), but I'm scratching my head to remember it.

How do I loop through each row of a multi-column range using Excel VBA? All the tutorials I've been searching up seem only to mention working through a one-dimensional range...


Solution

  • Dim a As Range, b As Range
    
    Set a = Selection
    
    For Each b In a.Rows
        MsgBox b.Address
    Next