Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I grab the last and second to the last values of an Excel table automatically?

I have a table, which you can find below, and I was hoping to calculate the WoW (Week over Week) percentage of the last two rows of the table. The calculation I use for percent change is =(E5/E4)-1

The thing is, this table updates every Friday, adding a new week, so instead of manually changing the formula (next week would be =(E6/E5)-1), I was hoping there would be a more automotive approach (whether it’s VBA or formulas).

Essentially, I am trying to pull the Page Views value from the last row of the table and the second to the last row of the table no matter how many records I add.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Week End Date Page Views
10/22/2021 35,604
10/29/2021 22,202
11/5/2021 49,921
11/12/2021 40,202

>Solution :

INDEX/MATCH will return the last and second to last:

=(INDEX(E:E,MATCH(1E+99,E:E))/INDEX(E:E,MATCH(1E+99,E:E)-1))-1

Basically:

INDEX(E:E,MATCH(1E+99,E:E))

Will return the last number in the column and:

INDEX(E:E,MATCH(1E+99,E:E)-1)

Will return the value one row above the last number in the column

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading