Beginner problem trying to iterate through a selection
Thank you, Jacob, but the goal wasn't to get to the final cell, but in
actually getting both steps to work seperately. See my reply to Dave in
order to understand why.
Steve
"Jacob Skaria" wrote in message
...
Please try this..
Sub Test()
For Each Row In Selection
ActiveCell.Offset(1, 0).Activate
Next
End Sub
If this post helps click Yes
---------------
Jacob Skaria
"Steve" wrote:
In Excel 2007, in tracing a problem I was having with a script, I
distilled
an issue down to the following:
---------------------------------------------
Sub Test()
For Each Row In Selection
ActiveCell.Offset(0, 1).Activate
ActiveCell.Offset(1, -1).Activate
Next
End Sub
---------------------------------------------
If I select a 2x2 range of cells, what I expect is that when stepping
through the above code, it changes the focus of the selection from (using
these as relative references to the selected range) A1 to A2 to B1 to B2
and
then exiting the script.
However, it does not update the row it thinks it's working on until it
goes
through it twice. Which means that for a selection that's 2 rows high,
it
loops 4 times, instead of 2.
What am I doing wrong?
|