Loop through each row of a range in Excel

Margaret picture Margaret · Sep 23, 2009 · Viewed 419.9k times · Source

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...

Answer

Mike picture Mike · Sep 23, 2009
Dim a As Range, b As Range

Set a = Selection

For Each b In a.Rows
    MsgBox b.Address
Next