Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I am ashamed not to know why this doesn't work... I am using old Excel 97 SR-2. The following code happily goes through each cell in the range from A1 to A5, and prints each address. Dim rngSELECT As Range Dim rngRange As Range Set rngSELECT = Range("A1:A5") For Each rngRange In rngSELECT Debug.Print rngRange.Address Next rngRange But, if I try to do the following: Dim rngSELECT As Range Dim rngRange As Range With Range("AddSELECT") Set rngSELECT = .Resize(.Rows.Count - 1, 1).Columns (1) 'returns $B$17:$B$226 End With For Each rngRange In rngSELECT Debug.Print rngRange.Address Next rngRange The above "For Each" loop is executed only once and gets out!!! "Set rngSELECT" sets the rngSELECT to $B$17:$B$226 before "For Each". On the first execution of "For Each" loop, rngRange.Address somehow returns the whole $B$17:$B$226!!! Why does it NOT return a single cell (address)??? I expect its address to be $B$17. I looked at some previous posts and it might be a problem to use collection in "For Each" loop in Excel 97... Thanks for your time, --- Tetsuya Oguma, Sydney, Australia |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Addin:Setting the range to the Excel.Range object range prop | Excel Worksheet Functions | |||
Excel 97 - Clear Method Of Range Object Failed | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming |