Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through range newbie question
Sorry, for what maybe a really simple question - i am a newbie.
I've found that I can loop through a range via the following statement: For Each c In MyRange.Cells Debug.Print c.Value Next However, I need to know when the next row starts, so I am looking to loop using the following construct: For Each oRow In MyRange.Rows For Each oCol In MyRange.Columns(oRow.index) Debug.Print oCol.Cell.Value Next Next But I can't figure out how to make it work. Is this possible? Or maybe I am taking the wrong approach? Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Looping through range newbie question
Frank,
Try something like this Sub PrintRangeValues(rngOutput As Range) Dim lRow As Long Dim nCol As Integer With rngOutput For lRow = 1 To .Rows.Count For nCol = 1 To .Columns.Count Debug.Print .Cells(lRow, nCol).Value Next nCol Next lRow End With End Sub Robin Hammond www.enhanceddatasystems.com "Frank Rizzo" wrote in message ... Sorry, for what maybe a really simple question - i am a newbie. I've found that I can loop through a range via the following statement: For Each c In MyRange.Cells Debug.Print c.Value Next However, I need to know when the next row starts, so I am looking to loop using the following construct: For Each oRow In MyRange.Rows For Each oCol In MyRange.Columns(oRow.index) Debug.Print oCol.Cell.Value Next Next But I can't figure out how to make it work. Is this possible? Or maybe I am taking the wrong approach? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Real Newbie newbie question | New Users to Excel | |||
Newbie Question - Subtraction Formula Question | Excel Discussion (Misc queries) | |||
looping question | New Users to Excel | |||
Looping Question | Excel Programming | |||
Looping question | Excel Programming |