Use "For... Each" to Iterate Through a Cells Collection?

B

BobbyMurcerFan

In Excel 2000 VBA, Is it possible to use "For... Each" to iterat
through a Cells collection?

Something along the lines of:

Code
-------------------

' ILLUSTRATIVE PSUEDO CODE THAT DOESN'T WORK

Dim celX as Cell ' I realze that Excel's VBA doesn't actually have a Cell object


' Iterate Through rngMyRange's Cells Collection
For Each celX in rngMyRange.Cells

MsgBox(celX.Value)

Next cel
-------------------

While I realize the above code won't actually work, IS there a way t
use For Each with the Cells collection?

Presently, I'm using the Count property to get the number of cells an
using that value in a For Loop iteration test.

Here's and example:

Code
-------------------
' WON'T WORK FOR CELL OBJECT
Sub ForLoopCell()

Dim iCntr As Integer, rngTest As Range

Set rngTest = ActiveSheet.Range("B1:B10")


' Iterate Through Cells Collection By Using A Counter
For iCntr = 1 To rngTest.Cells.Count

MsgBox (rngTest.Cells(iCntr).Value)

Next iCntr

End Su
-------------------


Using a For... Each would be easier, but is there a way to do it?

THANKS VERY MUCH!! :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top