I've been trying to write some code that will do a for/next loop through a non-contiguous range (referenced by named ranges, in case it makes a difference), but have been struggling to get anything working.
When referencing the range, instead of using the next item, it refers to the next cell.
For i = 1 To rngCategoryTops.Count
Debug.Print rngCategoryTops(i + 1)
What I'm actually trying to achieve (and perhaps there is a better way, is to have some VBA script parse a report worksheet and format it, depending on how many rows are required, either adding or removing rows as required. I've written code that goes through each section individually, but rather than have this duplicated according to how many sections there are, I'm much prefer to loop this.
I want to use For/Next rather than For Each, as I also need to refer to what is next up in the range, find it's location and work out how much space is needed so that the array doesn't #spill or so that there is only 2 blank rows in betwen each section.
Any help as to best do this would be gratefully received.
My thanks in advance.