Calculating value based on last occurence of a particular row!

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?
LVL 19
mrwad99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Try this...

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

Open in new window

and then copy it down.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mrwad99Author Commented:
Thank you very much!
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome!
0
mrwad99Author Commented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.