Reputation: 93
How can I change my excel formula if I need to replace direct reference to the cell by the column name of this cell? For example, instead of
SUM(A1:B1)
I want to use something like
SUM({Column1}:{Column2})
I know about structured reference, but I can not convert my excel dataset into named table. Do I have any options?
Upvotes: 0
Views: 3445
Reputation: 92
You can also name the "columns". You can do this by selecting the value including the header row and going to Formulas > Create from Selection or Ctrl + Shift + F3 and selecting only the Top row option.
Once done, you can create formulas using the header names instead of cell references.
Upvotes: 0
Reputation: 96753
This answer assumes that the column name
is the content of the header row for that column.
Say we have data like:
and we want to sum part of the row based on certain months, say between Feb and Jun. In B6 enter Feb and in C6 enter Jun and in D6 enter:
=SUM(INDEX(A2:L2,MATCH(B6,A1:L1,0)):INDEX(A2:L2,MATCH(C6,A1:L1,0)))
So by changing B6 and C6 we can change the part of the second row we are summing.
EDIT#1:
Upvotes: 2