views:

1392

answers:

2

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

+3  A: 

Something like this:

Dim rng As Range
Dim row As Range
Dim cell As Range

Set rng = Range("A1:C2")

For Each row In Rng.Rows
  For Each cell in row.Cells
    'Do Something
  Next cell
Next cell
David Andres
+4  A: 
Dim a, b As Range

Set a = Selection

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