Skip to content

Instantly share code, notes, and snippets.

@luane-aquino
Last active August 10, 2019 20:19
Show Gist options
  • Save luane-aquino/f84d2a48d03611616ecdf85dff624baa to your computer and use it in GitHub Desktop.
Save luane-aquino/f84d2a48d03611616ecdf85dff624baa to your computer and use it in GitHub Desktop.
Highlight every other row of current selection - LibreOffice/OpenOffice Calc macro
' 1- on LibreOffice Calc, select a range of cells
' 2- run the macro below
Sub HighlightRangeMacro()
Dim nCol As Long 'Column index variable
Dim nRow As Long 'Row index variable
Dim oCols 'Columns in the selected range
Dim oRows 'Rows in the selected range
Dim oRange
Const nCellBackColor = 15132415 ' "Blue gray"
oRange = ThisComponent.getCurrentSelection()
oCols = oRange.Columns : oRows = oRange.Rows
For nCol = 0 To oCols.getCount() - 1
For nRow = 0 To oRows.getCount() - 1 Step 2
oRange.getCellByPosition(nCol, nRow).setPropertyValue("CellBackColor", nCellBackColor)
Next
Next
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment