You can use one loop and fill two multiranges, one multirange for Bold and 2nd for Border. The use of multirange is the fastest for formatting many different cells.
Sub formatCells
on local error goto bug
dim oDoc as object, oSheet as object, oRange as object, i&
dim oRanges as object, oRangeAddress as new com.sun.star.table.CellRangeAddress, oRanges2 as object, oRangeAddress2 as new com.sun.star.table.CellRangeAddress
oDoc=ThisComponent
oSheet=oDoc.CurrentController.ActiveSheet
rem initial info for all ranges in multirange for BOLD
oRanges=oDoc.createInstance("com.sun.star.sheet.SheetCellRanges") 'object for multirange
with oRangeAddress
.Sheet=oSheet.RangeAddress.Sheet 'index of current sheet
.StartColumn=0 'column A (the indexing is from 0 -> the cell A1=0,0; B1=1,0 etc.)
.EndColumn=.StartColumn 'same column
end with
rem initial info for all ranges in multirange for BORDER
oRanges2=oDoc.createInstance("com.sun.star.sheet.SheetCellRanges") 'object for multirange
with oRangeAddress2 'initial info for all ranges in multirange
.Sheet=oSheet.RangeAddress.Sheet 'index of current sheet
.StartColumn=0 'column A (the indexing is from 0 -> the cell A1=0,0; B1=1,0 etc.)
.EndColumn=3 'column D
end with
for i=6 to 100 step 7 'from 1st Sat (indexing is like in sheet, so 1st line has 1 etc.)
rem set current range for BOLD
with oRangeAddress 'but here, the indexing of rows is from 0, so 6th line has index 5
.StartRow=i-1 'row with actual Sat
.EndRow=i 'row with actual Sun
end with
oRanges.AddRangeAddress(oRangeAddress, true) 'add the range to the multirange
rem set current range for BORDER
with oRangeAddress2
.StartRow=i 'row with actual Sun
.EndRow=.StartRow 'same row
end with
oRanges2.AddRangeAddress(oRangeAddress2, true)
next i
rem BOLD
oRanges.CharWeight=com.sun.star.awt.FontWeight.BOLD
rem BORDER
dim oBorder as new com.sun.star.table.BorderLine
with oBorder
.Color=RGB(200, 0, 150)
.OuterLineWidth=40
end with
oRanges2.BottomBorder=oBorder 'set the border
createUnoService("com.sun.star.frame.DispatchHelper").executeDispatch(oDoc.CurrentController.Frame, ".uno:Deselect", "", 0, array()) 'no selection
exit sub
bug:
bug(Erl, Erl, Error, "formatCells")
End Sub
And good sources for Basic macros
https://help.libreoffice.org/latest/en-US/text/sbasic/shared/main0601.html
https://wiki.documentfoundation.org/Documentation/DevGuide/LibreOffice_Basic
For Python sources please search the English - Ask LibreOffice :-).