Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

In Google Spreadsheet, I would like to find a column using a variable matching the column header and sum the column if the match is found.

Example:

-------------------
Ref | X  | Y  | z |
-------------------
A   | 3  | 4  | 2 |
-------------------
B   | 2  | 1  | 2 |
-------------------

What I need is to sum all of one column or all of one row (eg. B), not by referring directly to the row reference but by looking up "B" (or filtering "A" out).

How can I do that?

share|improve this question

1 Answer 1

You can use the following formula to accomplish that.

Formula

=SUM(INDIRECT(B1 & ":" & B1))

Explained

This formula can be used for rows and columns a like. It simply combines the input into a text range, that's being converted into a readable range, through the INDIRECT function.

Screenshot

enter image description here

Example

I've prepared an example file for you: sum column by referencing column header

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.