OpenOffice.org OpenOffice - 3.2 Základní průvodce Strana 354

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 497
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 353
which is more cumbersome than treating it as an array with two
dimensions as is done in Listing 5.
Listing 8. Add cell A2:C5 in every sheet
Function SumCellsAllSheets()
Dim TheSum As Double
Dim iRow As Integer, iCol As Integer, i As Integer
Dim oSheets, oSheet, oCells
Dim oRow(), oRows()
oSheets = ThisComponent.getSheets()
For i = 0 To oSheets.getCount() - 1
oSheet = oSheets.getByIndex(i)
oCells = oSheet.getCellRangeByName("A2:C5")
REM getDataArray() returns the data as variant so strings
REM are also returned.
REM getData() returns data data as type Double, so only
REM numbers are returned.
oRows() = oCells.getData()
For iRow = LBound(oRows()) To UBound(oRows())
oRow() = oRows(iRow)
For iCol = LBound(oRow()) To UBound(oRow())
TheSum = TheSum + oRow(iCol)
Next
Next
Next
SumCellsAllSheets = TheSum
End Function
Tip
When a macro is called as a Calc function, the macro cannot
modify any value in the sheet from which the macro was called.
Sorting
Consider sorting the data in Figure 288. First, sort on column B
descending and then column A ascending.
Figure 303: Sort column B descending and column A ascending
354 OpenOffice.org 3.x Calc Guide
Zobrazit stránku 353
1 2 ... 349 350 351 352 353 354 355 356 357 358 359 ... 496 497

Komentáře k této Příručce

Žádné komentáře