Dynamic formula for subtracting from two different cells.

Ali3ta1r

New Member
Joined
Nov 24, 2020
Messages
21
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am not sure if this is a simple question but seeking some advice on the below.

Is there a simple subtraction formula I can use between 2 cells that would work/update accordingly on visible data only?

At the moment I am using =A1-A2, but when I filter this it still accounts for the hidden data,

Kind Regards,
Alistair
 
I see Red alerts on the column M, N, O & P. what did They tell?(Topleft corner of each cell)
I see N2=L2*(I2-1) what is I .

I is the value that Column M is calculated from. A lengthy explanation of what it represents exactly, but it's a number.

It doesn't always apply, hence why sometimes Column M & N are blank.

It's also why I would like to filter by account and the data to update accordingly.
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
What is Your column format? (number Format)
and click on one of red alert and show it.
 
Upvote 0
Upvote 0
Book1
KLMNO
1StakeNew BankReturnedR.Stake£0.00
2£1.00-£1.00£20.00£1.00£21.00
3£1.00-£1.00£10.49£1.00£11.49
4£1.00-£1.00£0.00
5£1.00-£1.00£0.00
6£1.00-£1.00£0.00
7£1.00-£1.00£0.00
8£1.00-£1.00£0.00
9£1.00-£1.00£0.00
ALL
Cell Formulas
RangeFormula
M2:M3M2=K2*(I2-1)
N2:N3N2=K2
L2:L9L2=SUBTOTAL(109,O1)-SUBTOTAL(109,K2)
O2:O9O2=SUBTOTAL(109,L2)+SUBTOTAL(109,M2)+SUBTOTAL(109,N2)


Why is Cell M3 showing -£1.00 when I want it to show £20 (calculation of Cell O2- Cell K2)?

Sorry, I mean Cell L3 (not M3)
 
Upvote 0
For Table at Post #8 , Use this formula for M2:
Excel Formula:
=IF(OR(COUNTA($K$1:K1)=SUBTOTAL(103,$K$1:K1),SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2)))=0),P1-L2,INDIRECT("P"&SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2))))-L2)


And for P2:
Excel Formula:
=SUBTOTAL(109,N2,O2,M2)
 
Upvote 0
For Table at Post #8 , Use this formula for M2:
Excel Formula:
=IF(OR(COUNTA($K$1:K1)=SUBTOTAL(103,$K$1:K1),SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2)))=0),P1-L2,INDIRECT("P"&SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2))))-L2)


And for P2:
Excel Formula:
=SUBTOTAL(109,N2,O2,M2)

Alistair.xlsx
LMNOP
1StakeNew BankReturnedR.Stake£0.00
2£1.00-£1.00£20.00£1.00£20.00
3£1.00£19.00£10.49£1.00£30.49
4£1.00£29.49£29.49
5£1.00£28.49£28.49
6£1.00£27.49£7.03£1.00£35.52
7£1.00£34.52£34.52
8£1.00£33.52£33.52
9£1.00£32.52£32.52
ALL
Cell Formulas
RangeFormula
N2:N3,N6N2=L2*(I2-1)
O2:O3,O6O2=L2
M2:M9M2=IF(OR(COUNTA($K$1:K1)=SUBTOTAL(103,$K$1:K1),SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2)))=0),P1-L2,INDIRECT("P"&SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2))))-L2)
P2:P9P2=M2+N2+O2


So that has done something different, though when I filter the data according to Accounts it still uses values form the hidden cells.

So each Accounts' profit/loss still can't be calculated separately by filtering the data.
 
Upvote 0
OK. Then Use this (for M2 and drag it):
Excel Formula:
=IFERROR(INDIRECT("P"&SUMPRODUCT(MAX(ROW($K$1:K1)*(K$1:K1=K2))))-L2,INDIRECT("P"&SUBTOTAL(103,$K$1:K1))-L2)
 
Upvote 0
Book1
ABCDEFGHIJKLMN
1DateTimeCourseHorseBetSystemResultOddsStakeNew BankWinningsReturned Stake£0.00
218/09/202016.55AyrBlonde WarriorWinA12.60£1.00-£1.00-£1.00
318/09/202017.20NewburyAlways FearlessWinB13.30£1.00-£2.00-£2.00
418/09/202020.15KemptonTakeonefortheteamWinC6.25£1.00-£3.00-£3.00
518/09/202020.30DundalkSky SevenWinA9.48£1.00-£4.00-£4.00
619/09/202015.10Gowran ParkMr WendellWinC1st5.28£1.00-£5.00£4.28£1.00£0.28
720/09/202014.05HamiltonShesadabberWinC1st7.40£1.00-£0.72£6.40£1.00£6.68
820/09/202015.30Chelmsford CityGlobal ArtWinC1st13.00£1.00£5.68£12.00£1.00£18.68
921/09/202015.50FairyhouseLine JudgeWinA11.00£1.00£17.68£17.68
1021/09/202017.05HamiltonJohn JasperWinA8.20£1.00£16.68£16.68
1122/09/202014.30LingfieldHiroshiWinA4.27£1.00£15.68£15.68
1222/09/202016.15LingfieldCappananty ConWinA5.97£1.00£14.68£14.68
1322/09/202016.55BeverleyFirst ResponseWinA5.34£1.00£13.68£13.68
1423/09/202019.00KemptonNever AloneWinA5.70£1.00£12.68£12.68
1524/09/202013.00PontefractArceusWinC6.75£1.00£11.68£11.68
ALL
Cell Formulas
RangeFormula
L6:L8L6=J6*(H6-1)
M6:M8M6=J6
K2:K15K2=N1-J2
N2:N15N2=K2+L2+M2


Okay, still not working and I can't seem to get the red ! to return to check them.

However, it might help if I give some further data and information on the purpose of what I am seeking to do. So I bet on the horses using various systems (see Column F) and I track my results of all the systems on one single Excel sheet.

The starting bank is £0.00 (Cell N1) and I proof my systems to a level stakes bet of £1.00 (Column J).
After each bet, I show my bank minus the stake/bet; which is always £1.00 (Column K).
If the horse wins, my winnings (Column L) are calculated by the stake/bed multiplied by the odds -1 (Column H)
My bank after each bet (Column N) is calculated by the new bank minus stake (Column K) + any returned winnings (Column L) + the returned stake (Column M).

As you can see in the above example, the profile/loss is showing all my systems compiled (Column F). What I would like to do is filter my Systems (Column F) and for the financial calculations (Columns K, L, M and N) to update accordinly. So I can quickly check the profitability of each system individually, as well as all compiled together.

Is this possible?
 
Upvote 0
That should be working, but you change your data at columns. this is modified version based your new table. Please report problems. Input at K2 and drag it down:
Excel Formula:
=IFERROR(INDIRECT("N"&SUMPRODUCT(MAX(ROW($F$1:F1)*(F$1:F1=F2))))-J2,INDIRECT("N"&SUBTOTAL(103,$F$1:F1))-J2)
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

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