/ Published in: Other
page break inserted when first letter of first cell in row changes
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Sub Main Dim oSheets : Dim oSheet : Dim oUsedRange : Dim oCursor : Dim lastRow : Dim I As Integer : Dim oCell : Dim lastVal As String oSheets = ThisComponent oSheet = oSheets.Sheets(0) oUsedRange = oSheet.getCellRangeByPosition(0,0,0,0) oCursor = oSheet.createCursorByRange(oUsedRange) oCursor.GotoEndOfUsedArea(false) lastRow = oCursor.RangeAddress.EndRow for I = 0 to lastRow oCell = oSheet.getCellByPosition(0, I) if Left(oCell.String, 1) <> lastVal Then 'MsgBox Left(oCell.String, 1) oCell.Rows.IsStartOfNewPage = True endif lastVal = Left(oCell.String, 1) next I End Sub