# Best way to SUM all the columns between two particular columns

What should be the best approach to get a sum of cells that are between two columns A and E. Column A has a header of "Month Jan" and col E has a header of "Month Feb".

Columns are inserted and removed between A and E on daily basis. Meaning, sometimes column data with the header "Month Feb" is at col G, other times at col D.

Could something like this be useful? With INDEX and MATCH narrows to that column:

``````=SUM(A2:INDEX(A2:Z,,MATCH("Month Feb",A1:Z1,0)))
``````

If you want to skip last column add -1:

``````=SUM(A2:INDEX(A2:Z,,MATCH("Month Feb",A1:Z1,0)-1))
``````

## UPDATE

In order to include every column, going from Month Jan to Month Feb, even if there are added more columns to the left or right:

``````=SUM(INDEX(2:2,,MATCH("Month Jan",1:1,0)):INDEX(INDIRECT(ROWS(A:A)&":"&ROWS(A:A)),,MATCH("Month Feb",1:1,0)-1))
``````

I've added one extra row to the top, so you see it working in the green cell: I've added a GIF, but wasn't working well. Check here: https://docs.google.com/spreadsheets/d/1gbAd1bwF9Mt3H6K7Wh-iJlU-GuDMZ9-Qc3DWReiLuxE/edit#gid=628124778

• Hi Martin, thank you for taking the time to answer my question. Unfortunately that doesn't work in my case. Instead of -1, -2 worked somehow but not completly. By adding -2, I get the desired sum however when I add a column to the left of "Month Jan", sum function gives the wrong answer. Perhaps my question wasn't clear, my intention is to add everything in between two columns i.e. "Month of Jan" and "Month of Feb" irrespective of their column alphabet identity. Commented Jan 30, 2023 at 20:07
• I've understood what you said earlier, but given that columns are added to the left "-1" won't be as reliable. I've created one formula that will sum from row 2 to the end of the rows, in between "Month Jan" and "Month Feb" Commented Jan 30, 2023 at 20:25
• Wow it works, Thanks again. And now I can spend my coffee break on something productive, like learning the use of indirect and index/match in excel. Can't upvote your answer though, i don't habe enough "reputations". Commented Jan 30, 2023 at 20:38
• I'm glad it was useful. Basically I called the whole row 2:2 and the whole last row, and selected the cell from the columns that matched the headers. Good luck! (You can actually mark the question as answered) Commented Jan 31, 2023 at 0:08