Forum Discussion

ChristopheMoro2070's avatar
ChristopheMoro2070
Copper Contributor
Jan 27, 2023

Negative number change

Hi,

1-1-2023NL89TRIO0254663206107,35Debet  KNKosten van 01-10-2022 tot en met 31-12-2022
1-1-2023NL89TRIO02546632066.500,00CreditA.P.C.van Tetering eo A.C.J.van TetRABONL2U NL26RABO0159903408ETNo. 016868-001 Maroko reis 5 personen

 

if Colom D has text Debet, I would have change colom C to a negative number

 

Thanks 

C

  • ChristopheMoro2070 

    Spreadsheets are a type of functional programming environment and formulas are prevented from making state changes of the type you describe.  What you want could be achieved by a VBA (imperative programming) call that does use state changes.

    Unless you want to use VBA event handlers, I suggest you leave the amount cell as it is and only introduce the 'debit' when you reference the data.  You could, for example, introduce a named formula

    signedAmount
    = IF(Type="Credit", Amount, -Amount)

    Then you might have other spreadsheet formulas such as

    = SUM(signedAmount)
    
    = IF( signedAmount>0, 20% * signedAmount, 0 )

     

Resources