title: Setting a pagebreak based on row value in a cell?
body: <p>I have a report in Excel which generates a different amount of rows based on information in a record. I've set a hidden cell that prints the number of the last row, after which I would like the report to automatically set the page break, as currently I have to adjust it manually each time. </p>
  
  <p>I've tried </p>
  
  <pre><code>Worksheets("TIC").HPageBreaks.Add Before:=Worksheets("TIC").Rows(125)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Worksheets("TIC").Cells(1, 7).PageBreak = xlPageBreakManual
  </code></pre>
  
  <p>Cell 1,7 is the one with 125 value, which obviously changes depending on row length. </p>
  
  <p>Both of the examples above get executed but nothing changes in the report. </p>
  
  <p>Is it possible to do that in Excel automatically through VBA or is it a function that simply not possible?</p>