
If ActiveCell.FormulaR1C1 = "Site ID" Then The same for the Next B4 line.ĭo While ActiveCell.Row <=
#PAGE BREAK PREVIEW IN EXCEL FOR MAC CODE#
So, for the first appearance of Select in your code Range("A3").Select, you would 'Set' it as Set rngCurrentCell = Range("A3"). I would recommend using a Range as a reference and do all the tests "in memory".ĭim a range for tracking ( dim rngCurrentCell as range) and use that instead of the selecting the cells. Excel actually selects the cells as your code is running, making the code run slower (as you've noticed). The easy answer is that you use ActiveCell and Select and Activate. Private Sub LockInterface(ByVal interfaceOff As Boolean) PctProgress.ProgressText = "Set break point " & (CStr(passes) & "." & CStr(i)) wstWorksheet.Cells(lngRow, lngColSiteIDSecondary_c)

If LCase$(wstWorksheet.Cells(lngRow, lngColSiteIDSecondary_c).value) = "site id" Then If LenB(wstWorksheet.Cells(lngRow, lngColSiteIDSecondary_c).Formula) = 0& Then 'Checking the LenB is faster than a string check. 'Move the intended break point up to the first blank sectionįor lngRow = p.Location.Row - lngOffset_c To 1& Step -1& PctProgress.ProgressText = ("Row " & CStr(lngRow)) & (" of " & CStr(lngRowBtm)) WstWorksheet.Cells(lngRow, lngColSiteID_c).PageBreak = xlPageBreakManual If LCase$(wstWorksheet.Cells(lngRow, lngColSiteID_c).value) = "site id" Then 'LCase is to make comparison case insensitive. Public Sub PageBreak(ByRef wstWorksheet As Excel.Worksheet, ByVal pctProgress As ProgressCtl.ProgressContro)Ĭonst lngColSiteIDSecondary_c As Long = 1& Without knowing your data layout, it's hard to be sure if this code is 100% valid, so I would double check it for logic errors. I refactored the original code to give you an example of some of these ideas. If you know for a fact that it will be Cased that way you can of course remove the calls to LCase$ that I added.

PctProgress.ProgressText = "Set break point " & CStr(passes) & "." & CStr(i) 'Defaults the print area to be the entire sheet

'If this isn't performed beforehand, then the HPageBreaks object isn't available ' Marks that no rows/columns are to be repeated on each page This is the original code (sorry for the length): Public Sub PageBreak(ByRef wstWorksheet As Excel.Worksheet, ByVal pctProgress As ProgressCtl.ProgressControl) The code follows the above format: 2 loops doing those jobs. Group's aren't allowed to broken across pages.This part of the code runs after the main report is generated to set the page breaks in logical positions.
#PAGE BREAK PREVIEW IN EXCEL FOR MAC GENERATOR#
As part of an overhaul of a report generator I saw what I believed to be inefficient code.
