LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Beginner problem trying to iterate through a selection


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?


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterate over irregular shaped range problem Mark Hanley Excel Programming 3 February 22nd 09 01:14 PM
Right click and iterate through selection Paulymon Excel Programming 1 December 10th 05 08:31 PM
Beginner programmer problem Rednosebob Excel Programming 0 September 28th 04 09:17 PM
Beginner Variable Problem doc_in_bc[_4_] Excel Programming 6 May 29th 04 07:04 AM


All times are GMT +1. The time now is 09:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"