S
S
Sergey Goryachev2016-06-06 17:13:10
excel
Sergey Goryachev, 2016-06-06 17:13:10

LibreOffice Calc. How to add a number to all cells at once?

Hello.
How to add a certain number to all cells in LibreOffice Calc?
I have more than 800 lines in the price list, I need to add +60 rubles to all.
How to do it quickly?
You also need to take into account that there are empty lines between the positions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Fedoryan, 2016-06-07
@webirus

Sub Main
  Dim inc, row As Integer
  Dim rows, col As Integer
  Dim x As Object
  
  inc = 60  ' На сколько увеличить число
  rows = 20 ' Количество просматриваемых строк
  col = 0   ' Номер столбца для увеличения значений
  
  oDoc = ThisComponent
  row = 0
  Do While (row < rows)
    x = oDoc.Sheets(0).getCellByPosition(col, row) ' Первая страница текущего элемента (индекс 0)
    
    '  Проверка типа ячейки
    Select Case x.Type
      ' Если число
      Case com.sun.star.table.CellContentType.VALUE
        oDoc.Sheets(0).getCellByPosition(col, row).setValue(x.Value + inc)
      ' Если текст
      'Case com.sun.star.table.CellContentType.TEXT
      ' Если пусто
      'Case com.sun.star.table.CellContentType.EMPTY
      ' Если формула
      'Case com.sun.star.table.CellContentType.FORMULA
        
    End Select
    
    row = row + 1
  Loop
End Sub

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question