View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Index on a selection

I don't think that there's a better way to do than to count the cells yourself.

But you do have a few choices.

You could do:

dim myRng as range
dim myCell as range
dim iCtr as long

ictr = 0
set myrng = range("c5:e12")
for each mycell in myrng.cells
ictr = ictr + 1
msgbox ictr & "--" & mycell.address(0,0)
next mycell

to see how the "pattern" that mycell takes.

=============

or you could loop through the columns of the range:

dim myRng as range
dim myCol as range
dim myCell as range
dim iCtr as long

ictr = 0
set myrng = range("c5:e12")
for each mycol in myrng.columns
for each mycell in mycol.cells
ictr = ictr + 1
msgbox ictr & "--" & mycell.address(0,0)
next mycell
next mycol

And see that pattern.

The same kind of thing to loop through each row.

"[KiO] ASamarcos" wrote:

Hi Peterson.

Thanks for your help, but I actually want a way to see the index of the
cell that is being processed by the for each next routine.

Imagine that Selection.Count gives me 40. 40 cells in the range I
selected.

When the For Each starts I want to know, on each step, where the count
is. Is it 1, 2, 37?

I thought the Cell.Index could give me the answer but returns a error
message and I think theres a better way to do that than to put a
counter on it.

Best Regards,
KiO

--
[KiO] ASamarcos
------------------------------------------------------------------------
[KiO] ASamarcos's Profile: http://www.excelforum.com/member.php...o&userid=37554
View this thread: http://www.excelforum.com/showthread...hreadid=571874


--

Dave Peterson