Excel SUM current column (via Excel::Template)

1.1k Views Asked by At

I'm using Excel::Template to generate a series of Excel files via perl. However, I need to do a SUM function on the current Column. I know I can do

=SUM(3:15)

but that gives the sum of ALL columns in rows 3-15. Is there an easier way to do what I'm trying to do?

2

There are 2 best solutions below

1
On BEST ANSWER
=sum(indirect(concatenate(address(<row_start>,column()),":")&address(<row_end>,column())))

gives me exactly what I need. Not exactly sure how it works, but found on MrExcel.com

2
On

For column C,

=SUM(C3:C15)

Since =SUM(...) is just a string, you may have to parametrize the column if you don't know it before runtime. For instance

$str = "=SUM(" . col_char . "3:" . col_char . "15)";