Calculating value based on last occurence of a particular row!

mrwad99
mrwad99 used Ask the Experts™
on
Ah hello.

This might be a simple question, but I am a C++ programmer by trade and don't know much about Excel.  So please bear with me :)

I am analysing a network packet trace and have extracted relevant data into the attached spreadsheet.  



Long story short, I need to automatically calculate values in the "A-S" column.  The pseudo-code for doing this is:

while we have not run out of rows
     while value in first column is an S
        remember the value in the VALUE column
        go onto the next row

        (At this point, the value in the first column for the current row is an 'A')
        Subtract the remembered 'S' value from the current row's VALUE
        Write this value into the A-S column for the current row

        Go onto the next row

Open in new window


I haven't got a clue how to do this.  Can someone please advise?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015
Commented:
Try this...

In D2
=IF(AND(A2="A",A1="S"),C2-C1,"")

Open in new window

and then copy it down.

Author

Commented:
Thank you very much!
Subodh Tiwari (Neeraj)Excel & VBA Expert
Most Valuable Expert 2018
Awarded 2015

Commented:
You're welcome!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial