cancel
Showing results for 
Search instead for 
Did you mean: 

Autosum formula in Excel

LourdesUrena
Level 5
We have a process which sends a spreadsheet through e-mail. The amount of rows the spreadsheet contains is variable as it depends on the amount of data the customer has at a certain point in time. One of the columns is amount and we would like for the spreadsheet to sum up all the amounts in the respective column, but can't seem to find a way to do so. We though about setting the value of the cell by getting the last cell that has data and then writing the formula as a text, but it didn't work. I also tried recording a macro with Excel by doing relative reference, but since the amount of rows changes every time I can't setup a dynamic feature in order to the cell to read the first row with data everytime (the amount of rows it has to go up changes every time from 0 to infinite) Any other ideas of how to input the autosum formula?
Lourdes Urena Sr Solutions Engineering Grainger Panama Services Panama
2 REPLIES 2

Denis__Dennehy
Level 15
You have lots of options available to you: * Read in the data you want to sum up (maybe using get worksheet range as collection) then loop through the collection adding up the total * You could use the OLEDB VBO to connect to your worksheet and perform queries and updates in the same way you would a database * You can create a new Excel VBO action that does something you need - so get googling for how to do an Autosum

Gilberto.lopez
Level 3
You can use this code to set a formula in excel. GetInstance(handle).ActiveCell.Formula =""=SUM (""& value &"")""   value must be the range for example: ""A1:A10