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 Loop through range issue

Greetings all -

My problem is one of understanding or lack of it! :

I wish to loop through the first column of a range. I set a range
object to equal the first column of my range. I then attempt to loop
through each cell in my now - single column range. Yet for reasons I
don't understand my Cell range is now the same as rRange and the
process fails

Sub xx()
Dim Cell As Range
Dim rRange As Range

Set rRange = Range("A1:B20").Columns(1)
For Each Cell In rRange
Debug.Print Cell.Address
Next
End Sub

However if I do the following it works perfectly

Sub x()
Dim Cell As Range
Dim rRange As Range

Set rRange = Range("A1:B20").Columns(1)
For Each Cell In Range(rRange.Address)
Debug.Print Cell.Address
Next
End Sub

Any thoughts would be appreciated - note that I am keen to understand
the issue not solve it another way

Cheers

Kieran

 
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
For next do loop issue Christian Falde Excel Discussion (Misc queries) 4 November 11th 08 07:01 PM
Range issue evil baby[_13_] Excel Programming 3 March 7th 06 03:59 PM
do ... until loop issue pjjclark Excel Programming 4 November 29th 05 04:24 PM
Issue with Do Loop Linking to specific cells in pivot table Excel Programming 3 July 24th 05 10:38 PM
Add a Range to an existing Range in a loop? Mick Excel Programming 3 June 18th 05 06:12 AM


All times are GMT +1. The time now is 09:42 PM.

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"