Question

How to add several values ​​that can be negative or positive, and accumulate later in separate variables

  • 22 April 2023
  • 1 reply
  • 147 views

Userlevel 1
Badge +7

Good Afternoon to everybody

How to add several values ​​that can be negative or positive, and keep accumulating the Positive values ​​in one variable and the Negative ones in another variable? My task will go through a column in Excel that can have as many positive and negative values ​​in the same column. I have to go accumulating the negative and positive values, adding them up and obtaining in the final variables, the "accumulated" value, of the positive values ​​and the negative values.

 


1 reply

Badge +2

@interplan  if you want to get the sum of Positive and negative numbers in an excel Column you can can try this code. it does the same 

  1. Open  Excel file
  2. Loop through the column you want to get sum of +ve or -ve numbers
  3. check if the Current value of a loop is -ve number Using String Include Condition
  4. inside if or else you can add get the sum of the current value + Previous sum

 

Reply