Matthew -
Does each row contain the same number? Do all the areas contain the same
rows?
I'm thinking you could iterate through the rows of the worksheet, and in
each row, do something like
for each wsRow in ActiveSheet.Rows
for each rArea in rDiscontiguousRange.Areas
if not intersect(rArea, wsRows(i)) is nothing then
intersect(rArea,wsRow).value = NumberForThatRow
end if
next
next
- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
http://PeltierTech.com/Excel/Charts/
_______
Matthew Wieder wrote:
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!