Skip to content

Instantly share code, notes, and snippets.

@mopperwhite
Created January 6, 2017 16:15
Show Gist options
  • Save mopperwhite/ff5e5990791da489b74c85daaafde56c to your computer and use it in GitHub Desktop.
Save mopperwhite/ff5e5990791da489b74c85daaafde56c to your computer and use it in GitHub Desktop.
LibreOffice Basic
REM ***** BASIC *****
Sub Main
Dim xUntil, yUntil as integer
Dim left, cleanCol As Integer
Dim isEmptyCol as boolean
left = 0
xUntil = 10
yUntil = 10
xSheet = ThisComponent.Sheets(0)
for i = 0 to xUntil
isEmptyCol = True
for j = 0 to yUntil
color = xSheet.getCellByPosition(i, j).CellBackColor
if color <> -1& Then
isEmptyCol = False
endif
next j
if not isEmptyCol then
for j = 0 to yUntil
dCell = xSheet.getCellByPosition(left, j)
sCell = xSheet.getCellByPosition(i, j)
dCell.String = sCell.String
color = sCell.CellBackColor
dCell.CellBackColor = color
next j
left = left + 1
cleanCol = i
endif
next i
if left < cleanCol then
for j = 0 to yUntil
sCell = xSheet.getCellByPosition(cleanCol, j)
sCell.String = ""
sCell.CellBackColor = -1
next j
endif
End Sub
Sub Macro1
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment