View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Matthew Wieder Matthew Wieder is offline
external usenet poster
 
Posts: 48
Default Non-Contiguos Range Iteration

I have a complex calculation that I need to write in VBA which can be
represented with the following example. I need to iterate through all
the cells in a noncontiguous range and starting from 1, put the number
of the rows iterated through into the cells in that row so I end up with
something like this:
J K L T U


313 1 1 1 1 1
314 2 2 2 2 2
315 3 3 3 3 3

The problem is that the method for iterating through a noncontiguous
range treats the cells as unrelated and hence I would have to iterate
through the J313:L315 range and only then go on to the T313:U315 range,
in which case I lose the count of the rows. (in the actual case, the
values to be placed in the rows is much more difficult to re-compute
then the row number). What I need to do, is iterate through row 313
(J-L, T-U), then row 314(same) then row 315(same).

Is there an easier way to do this?
thanks!