Search code examples
excelcsvexport-to-excelexport-to-csv

Excel functions with dynamic range


So I am creating a .csv file with data I want to plot in excel, however I want to plot the sum of them. e.g.

set 1:

0 5 6 67
5 6 1 0

set2:

8 5 4 664
1 2 5 694
6 4 1 545

So I want the sum of each column in set1 as a row in the end and the sum of each column in set2 at the end. But the problem is that set1 and set2 might have a different number of rows.

Is there any easy FORMULA that I can export with the .csv to do so in excel?


Solution

  • I don't know if I understand your question correctly, but you might try this:

    Assuming that the top left number is in Cell A1, you could use the following formula:

    =SUM(OFFSET($A$1, 0, COLUMN()-1, ROW()-1, 1))
    

    Print this into every cell of the last row of your sheet. This way, you have a fixed formula for every cell that works regardless of the number of columns or rows, even when the rows have different lengths.

    Example for set2:

    8   5   4   664
    1   2   5   694
    6   4   1   545
    15  11  10  1903    <-- formula pasted here