Skip to content

Instantly share code, notes, and snippets.

@eniehack
Created August 16, 2021 17:03
Show Gist options
  • Save eniehack/e2f4006397cb24d7d831aa27d6b228f2 to your computer and use it in GitHub Desktop.
Save eniehack/e2f4006397cb24d7d831aa27d6b228f2 to your computer and use it in GitHub Desktop.
Sub Main
dim units_sum(5) as integer
dim sheet as object
dim i()
dim val as integer
sheet = ThisComponent.Sheets(0)
units = sheet.getCellRangeByName("C3:F44").getDataArray()
for each i in units()
rem print CStr(i(0)) + CStr(i(1))
Select Case i(1)
Case 1:
units_sum(0) = units_sum(0) + i(0)
Case 2:
units_sum(1) = units_sum(1) + i(0)
Case 3:
units_sum(2) = units_sum(2) + i(0)
Case 4:
units_sum(3) = units_sum(3) + i(0)
Case 5:
units_sum(4) = units_sum(4) + i(3)
Case Else:
End Select
Next i
for val = 0 to 4
rem Print CStr(val+1) + ": " + CStr(units_sum(val))
ThisComponent.Sheets(1).getCellByPosition(val+2, 3).Value = units_sum(val)
next val
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment