View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default For Loop in Sub Detailloop

Bruce-

Don't let this go to your head, but this code is the 97 pound weakling to
Charles Atlas. I'm sure it does something quite simple if only I could
understand it. Your biggest problem is that you have unintended circular
calls (I think). HeaderRecord2 calls DetailLoop which calls summonth which
calls HeaderRecord2. This is circular and will never resolve except by a
macro error. You must restructure this and I'd bet that that restructuring
would require the elimination of summonth's call to HeaderRecord2. At some
point, in any case, some sub has to just return without calling anything.

I don't know what you're doing with i. Nothing within the loop seems to
vary with different i's so it seems to be doing the same thing time after
time.

Btw, code like:

ActiveCell.Offset(0, 0).Value = Range("Sum_it").Offset(0, 0)
ActiveCell.Offset(1, 0).Value = Range("Sum_it").Offset(1, 0)
ActiveCell.Offset(2, 0).Value = Range("Sum_it").Offset(2, 0)
....
ActiveCell.Offset(7, 0).Value = Range("Sum_it").Offset(7, 0)


can be made a one-liner:

ActiveCell.Resize(7).Value = Range("Sum_it").Resize(7).Value


--
Jim Rech
Excel MVP