Cell Calculation

I am using LibreOffice Calc to set up my store’s inventory. In one column, I have a “Price” column. Is it possible to format the cells in that column to calculate “price” instantly? Let me explain this more, so for example in a cell on the “Price” column, I enter in 20, it would then change that to 55. The change is based on a formula for margin increase. I am aware that I can do this if I create another column and put the wholesale price of 20 there and use the Price column to calculate the margin increase of the wholesale price, however in my circumstance, I can’t because this is a spreadsheet to be uploaded.

Hi

I do not understand why the fact that the spreadsheet is uploaded prevents add a calculation column. However, to answer the question, I do not think there is solution without macro. The macro can be associated with the event Content changed: Right click sheet tab > Sheets Events. Note: this depends on the authorization of the execution of macros. This solution is not necessarily better than the addition of a calculation column. May I add that, as a user, I would hate not to see what I entered :slight_smile:

AutoCalc.ods

Code Sample (the number of the column to be treated is declared “constant” at the beginning. Warning: Column A has the number zero. In Example 3 refers to the column D):

const NumCol=3

Sub PysAutoCalc(oEvent)
' If the changed item is a cell'
if oEvent.supportsService("com.sun.star.sheet.SheetCell") then
' If it is in the column'
	if oEvent.CellAddress.column = NumCol then
' If it is a value'
		if oEvent.Type = com.sun.star.table.CellContentType.VALUE then
' do some stuff...'
				oEvent.value = oEvent.value * 1.1
		end if
	end if
end if
End Sub

Using paste special:

a) Put the value to use for update the values in a cell.
b) Copy that cell.
c) Select the range to modify.
d) Menu/Edit Paste special [Shift+Ctrl+V]
e) Select the operation to apply.
Ok.