Question : Looping a range...

If doing a loop on a range can I dictate the direction the range is read? For instance when looping the range is being read from left to right starting with the top row. I'd like to loop from top to bottom starting with the first column.

For each x in range
...
next x


Any thoughts?

NG,

Answer : Looping a range...

NG,

You can do something like this:


    Dim RngRows As Long, RngCols As Long
    Dim r As Long, c As Long
    Dim rng As Range

    Set rng = Range("A4:D17")
    With rng
        RngRows = .Rows.Count
        RngCols = .Columns.Count
        For c = 1 To RngCols
            For r = 1 To RngRows
                MsgBox .Cells(r, c).Address & " is Row " & r & " and Column " & c
            Next
        Next
    End With
Random Solutions  
 
programming4us programming4us