Lookup and subtract

milesy

New Member
Joined
Jan 1, 2014
Messages
23
Office Version
  1. 365
Platform
  1. Windows
HI all

im after some help to solve an issue i have a spreasheet that looks like the below image

what i need to do is a script that will look at Column C and in the first instance return the value of Column H into say Column Z
then for the NEXT instance of the same value in Column C return the result of Z- the new value of H

So for the below example
C00684 first instance Z would be 76 - Column H (20) so 56
Second instance of C00684 would be Z(56) subtracting the new value of I (in this instance 50 ) so Z on row 81 would be 6
etc etc etc

any one care to help here?



1594023706184.png
 

Attachments

  • 1594023393502.png
    1594023393502.png
    56.7 KB · Views: 2
  • 1594023565610.png
    1594023565610.png
    46.3 KB · Views: 2

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about
=INDEX($I$2:$I$100,MATCH(C2,$C$2:$C$100,0))-SUMIFS($H$2:$H$100,$C$2:$C$100,C2)
 
Upvote 0
interesting looks close but not quite right.....

i think this works based on your suggestion

=INDEX($I$2:$I1705,MATCH(C1705,$C$2:$C1705,0))-SUMIFS($H$2:$H1705,$C$2:$C1705,C1705)
 
Upvote 0
:unsure: That looks to be exactly the same formula, just looking at a different cell. :unsure:

Glad it's sorted & thanks for the feedback.
 
Upvote 0
lol actually the change was simply to remove the abosolute settings on the match....what it was doing (which wasnt quite what i wanted) was subtracting all the quantites at once rather than a starting piont....then subtract each value as it went
either way thank you so much for your help
 
Upvote 0
Got it, & thanks for the feedback.
 
Upvote 0
Can i ask you (or anyone else who might know) ......with the above formula i would like to be able to run a macro which would basically ask me for the columns that apply

what i mean is from the code above there are four sections

INDEX($I$2:$I2,MATCH(C2,$C$2:$C2,0))-SUMIFS($H$2:$H2,$C$2:$C2,C2)

the first section in this instance is Column I, the second Column C the third H and the final C

so i would want a macro (or script) to pop up and ask me
1. Where to paste the finished result,
2 which column is the Qty on hand (Column I),
3. which columns is the Part Number (Column C)
4. Which Column is the used qty (Column H)

and then paste the final formula with the details filled in, this would make this report and the responding code very very usable?

Adrian
 
Upvote 0
As that is a totally different question, you will need to start a new thread. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top