OK this is not a question, just a discovery.

I am doing some reporting in Excel programatically. In the main loop, I was adding a page break where it was supposed to go like:

VB Code:
  1. mwksTemp.HPageBreaks.Add rngReport.Range(strRange)

This was making my code run increadibly slow, approx. 100 times slower if not worse.

Instead, I saved the placement of the pagebreak in a collection like:

VB Code:
  1. colPageBreaks.Add strRange

and, after the looping was all finished, I add the page breaks like:

VB Code:
  1. For each varPageBreak in colPageBreaks
  2.     mwksTemp.HPageBreaks.Add rngReport.Range(varPageBreak)
  3.   Next

The lesson is only to never place pagebreaks inside of a looping algorithm because of the insane time growth problem.