Iterating on several Cells within a Row
What you write is true. I'm not sure how it relates to my code fragment
posted and the issue I was having with it. Let me put a pair of comments in
the fragment to better explain:
For Each myRow In myRange.Rows
' is it a line we need to get the column data from?
If myRow.Cells(, ColX) = AmagicValue Then
' if it's magic, let's iterate on the cells of this row_
from column ColY to column ColZ
For Each myCell In myRow.Range( _
myRow.Cells(, ColY), _
myRow.Cells(, ColZ) _
).Cells
' do what we need to do with each of the _
subset of cells in our columns in the magic row
' problem was that here myCell.Address was pointing _
to a different row than myRow.Address, thus_
hosing everything up
Next myCell
End If
Next myRow
' problem wasn't a reference to myRow or _
myCell here outside of the For Each...
In any event, Jakob's posting sorted it out. Thanks for offering to help!
"Joel" wrote in message
...
No. See comments below.
For Each myRow In myRows.Rows
For Each myCell In myRow.Range( _
Next myCell
Next myRow
'this statement is not valid since myrow is outside the for loop
RowCount = myrow.row
|