Hi.

How to in LibreOffice Calc to add to all cells a certain number?

I have over 800 rows in the price list, you need to add to all +60 rubles.

How to do it quickly?

You also need to consider that between the positions of the is and empty string.

How to in LibreOffice Calc to add to all cells a certain number?

I have over 800 rows in the price list, you need to add to all +60 rubles.

How to do it quickly?

You also need to consider that between the positions of the is and empty string.

asked July 8th 19 at 16:12

2 answers

answered on

Solution

```
Sub Main
Dim inc, row As Integer
Dim rows, col As Integer
Dim x As Object
inc = 60 ' how to increase the number
rows = 20 ' the Number of rows scanned
col = 0 ' column Number for increasing values of
oDoc = ThisComponent
row = 0
Do While (row < rows)
x = oDoc.Sheets(0).getCellByPosition(col, row) ' the First page of the current element (index 0)
'Check type of the cell
Select Case x.Type
'If the number
Case com.sun.star.table.CellContentType.VALUE
oDoc.Sheets(0).getCellByPosition(col, row).setValue(x.Value + inc)
'If the text
Case com.sun.star.table.CellContentType.TEXT
'If empty
Case com.sun.star.table.CellContentType.EMPTY
'If formula
Case com.sun.star.table.CellContentType.FORMULA
End Select
row = row + 1
Loop
End Sub
```

answered on

Solution

In a separate cell put the amount the size of which you want to increase all the rest ( in this case 60). Next, the copy button (to copy the cell 60). Select all the numbers that need to increase, then the function "paste Special" choose operation "Fold" and click OK

Find more questions by tags LibreOfficeExcel