Search code examples
google-sheetsexcel-formulasumgoogle-sheets-formulavlookup

How to subtract range from last non empty cell to first?


I am a beginner in google sheets and I couldn't get around this formula. I have range of cells and I want to subtract last non empty cell to first cell (Z-A), here is the image:

Subtract values

As the values are updated in columns C, D, E and so on. I want to get the last non empty cell (from right) and subtract the values by moving backward (left). Like this:

sub = 10(Column G)-0(Column F)-10(Column E)-0(Column D)-10(Column C)

Can we devise a formula which will get the last non empty cell and subtract values until the first value? Here is the link to the sample sheet Thank you


Solution

  • try:

    =LOOKUP(1, INDEX(1/(C2:F2<>"")), C2:F2)-(SUM(C2:F2)-
     LOOKUP(1, INDEX(1/(C2:F2<>"")), C2:F2))
    

    enter image description here