Sum and subtraction

%3CLINGO-SUB%20id%3D%22lingo-sub-1960029%22%20slang%3D%22en-US%22%3ESum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960029%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFirst%2C%20I'm%20sorry%20for%20my%20english%20(I%20used%20the%20google%20translator%20to%20help%20me)%3C%2FP%3E%3CP%3Ei%20have%20three%20cells.%20a1%20a2%20and%20a3.%3C%2FP%3E%3CP%3Ea3%20is%20sum%20of%20a1%2Ba2%26nbsp%3B%3C%2FP%3E%3CP%3Ea3%3D%20a1%20%2Ba2%2C%20example%208%20%3D%202%2B6%2C%3C%2FP%3E%3CP%3E%26nbsp%3Bbut%20I%20want%20also%20be%20possible%20when%20i%20put%3A%3C%2FP%3E%3CP%3Ea1%20%3D%20a2-a3%20or%3C%2FP%3E%3CP%3Ea2%20%3D%20a1-a3%3C%2FP%3E%3CP%3Eregardless%20where%20I%20put%20the%20values%20it%20calculates%20the%20third%20value%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1960029%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960281%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960281%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F892454%22%20target%3D%22_blank%22%3E%40Ramsousa1986%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20would%20result%20in%20circular%20reference%2C%20as%20explained%20here%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fremove-or-allow-a-circular-reference-8540bd0f-6e97-4483-bcf7-1b49cd50d123%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsupport.microsoft.com%2Fen-us%2Foffice%2Fremove-or-allow-a-circular-reference-8540bd0f-6e97-4483-bcf7-1b49cd50d123%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960282%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960282%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F892454%22%20target%3D%22_blank%22%3E%40Ramsousa1986%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20am%20afraid%20that%20this%20doesn't%20make%20sense.%3C%2FP%3E%0A%3CP%3EIn%20the%20first%20place%2C%20a1%20%3D%20a2-a3%20and%20a2%20%3D%20a1-a3%20are%20not%20equivalent%20to%20a3%20%3D%20a1%2Ba2.%3C%2FP%3E%0A%3CP%3EIn%20the%20second%20place%2C%20what%20do%20you%20want%20to%20happen%20when%20you%20change%20one%20cell%3F%20Which%20cell%20should%20be%20kept%20the%20same%2C%20and%20which%20one%20should%20be%20changed%3F%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20if%20I%20change%20cell%20A1%2C%20should%20I%20change%20the%20sum%20in%20A3%2C%20or%20should%20I%20keep%20the%20sum%20the%20same%20and%20change%20cell%20A2%20so%20that%20A3%20still%20equals%20A1%2BA2%3F%3C%2FP%3E%0A%3CP%3EAnd%20if%20I%20change%20cell%20A3%2C%20should%20I%20keep%20A1%20the%20same%20and%20change%20A2%2C%20or%20should%20I%20keep%20A2%20the%20same%20and%20change%20A1%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960284%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960284%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F280482%22%20target%3D%22_blank%22%3E%40Twifoo%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhile%20formulas%20would%20lead%20to%20circular%20references%2C%20it%20could%20be%20done%20using%20VBA%20-%20if%20it%20were%20clear%20what%20the%20OP%20actually%20wants.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960285%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960285%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F892454%22%20target%3D%22_blank%22%3E%40Ramsousa1986%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20explain%20what%20it%20is%20you%20trying%20to%20accomplish%20through%20this%20calculation%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20the%20moment%2C%20you%20are%20experiencing%20a%20circular%20reference%20in%20excel%20since%20all%20the%20cells%20are%20referencing%20one%20another%20and%20no%20clear%20%22source%22%2Fnumber%20is%20manually%20inputted%20for%20a%20calculation.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960507%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867265%22%20target%3D%22_blank%22%3E%40adversi%3C%2FA%3E%26nbsp%3Band%20the%20rest%20people....%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20let%20me%20try%20explain%20again...%3C%2FP%3E%3CP%3EThis%20is%20my%26nbsp%3BSpreadsheet%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20370px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F238102iB81A888F2AE97E0C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3Ecolumns%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3EN.%20Dev%20-%3C%2FSTRONG%3E%20is%20to%20identify%20the%20document%20(In%20this%20document%20(invoices%20and%20others)%20I%20have%20products%20with%206%25%20tax%2C%2023%25%20tax%20and%20the%20total%20sum%20of%20the%20two%20tax.%3CBR%20%2F%3EI%20have%20to%20separate%20the%20products%20by%20tax)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E6%25%20-%3C%2FSTRONG%3E%20is%20tax%20produt%20(it's%20not%20important%20to%20what%20I%20want%20right%20now)%3C%2FP%3E%3CP%3E%3CSTRONG%3E23%25%3C%2FSTRONG%3E%20-%20is%20tax%20produt%26nbsp%3B%20(it's%20not%20important%20to%20what%20I%20want%20right%20now)%3C%2FP%3E%3CP%3E%3CSTRONG%3ETotal%3C%2FSTRONG%3E%20%3D%206%25%20%2B%2023%25%26nbsp%3B%3C%2FP%3E%3CP%3E---------------%2F%2F--------------%3C%2FP%3E%3CP%3EI%20have%20to%20enter%20the%20values%20of%206%25%20and%2023%25%2C%20then%26nbsp%3Bthe%20sum%20appears%20in%20column%20%22F%22%3C%2FP%3E%3CP%3EImage%20i%20put%20%3A%26nbsp%3B%20%26nbsp%3BC17%2BE17%20%3DF17%3B%205%2B6%3D11%E2%82%AC%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ebut%20sometimes%20it%20would%20be%20easier%20for%20me%20if%20I%20put%20the%20value%206%25%20and%20the%20total%20and%26nbsp%3B%20%22excel%22%20calculate%20the%20value%2023%25%2C%3B%20example%20F17%20-%20C17%20%3D%20E17%3B%2011%E2%82%AC%20-%205%E2%82%AC%3D%206%E2%82%AC%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3Eor%20put%20the%20value%20of%2023%25%20and%20the%20total%20and%20calculate%20the%20value%20of%206%25%20%3A%20example%20F17%20-%20E17%20%3D%20C17%3B%2011%E2%82%AC%20-%206%E2%82%AC%20%3D%205%E2%82%AC%3C%2FP%3E%3CP%3Eregardless%26nbsp%3B%20where%20i%20places%20the%20values%2C%20he%20can%20calculate%20the%26nbsp%3Bthe%20third%20value.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960512%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960512%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F892454%22%20target%3D%22_blank%22%3E%40Ramsousa1986%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20remains%20problematic.%3C%2FP%3E%0A%3CP%3ELet's%20say%20you%20have%20entered%205%20in%20C16%20and%206%20in%20E16.%20The%20sum%2011%20is%20calculated%20in%20F16.%3C%2FP%3E%0A%3CP%3ENow%20you%20discover%20that%20C16%20should%20actually%20have%20been%204.%3C%2FP%3E%0A%3CP%3EHow%20should%20Excel%20decide%20whether%20you%20want%20to%20update%20the%20total%20in%20F16%20to%204%2B6%20%3D10%2C%20or%20you%20want%20to%20adjust%20E16%20to%2011-4%3D7%2C%20keeping%20the%20total%20the%20same%3F%3C%2FP%3E%0A%3CP%3EDo%20you%20have%20a%20decision%20rule%20for%20that%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960513%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960513%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F892454%22%20target%3D%22_blank%22%3E%40Ramsousa1986%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20clarifying.%20There%20are%20multiple%20ways%20to%20%22automate%22%20this%20issue%20to%20speed%20up%20your%20process.%20Are%20the%20documents%20you're%20using%20to%20count%20the%20number%20of%20products%20in%20a%20spreadsheet%20or%20are%20you%20manually%20counting%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20this%20is%20already%20in%20a%20spreadsheet%2C%20then%20a%20function%20can%20be%20used%20rather%20than%20a%20complex%20nested%20formula%20to%20allow%20for%20dynamic%20cell%20inputs.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960561%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960561%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F867265%22%20target%3D%22_blank%22%3E%40adversi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3E%22Are%20the%20documents%20you're%20using%20to%20count%20the%20number%20of%20products%20in%20a%20spreadsheet%20or%20are%20you%20manually%20counting%3F%22%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20dont%20need%20count%20the%20number%20of%20products.%20I%20just%20need%20to%20put%20the%20total%20of%206%25%20products%2C%20and%2023%25%20products%20then%2C%20sum%20total%20of%206%25%20and%2023%25.%20(i%20just%20need%20the%20value%20%22%E2%82%AC%E2%82%AC%E2%82%AC%22%2C%20i%20dont%20care%20if%20i%20have%201%20or%2023%20products%2C%20for%20example).%26nbsp%3B%3C%2FP%3E%3CP%3Eexample%3A%20Invoice%20n%C2%BA%202535%20-%20have%20total%20tax%206%25%20of%20300%E2%82%AC%20and%20total%2023%25%20tax%20of%20500%E2%82%AC%3B%20Sum%20tax%20%3D%20800%E2%82%AC%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960584%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960584%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F892454%22%20target%3D%22_blank%22%3E%40Ramsousa1986%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELet%20me%20rephrase%20-%20is%20the%20source%20you're%20using%20for%20the%20input%20already%20in%20a%20spreadsheet%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1960611%22%20slang%3D%22en-US%22%3ERe%3A%20Sum%20and%20subtraction%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1960611%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGreat%20question!%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EDo%20you%20have%20a%20decision%20rule%20for%20that%3F%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3Ewhat%20can%20I%20say%3F%20in%20my%20documents%20I%20always%20have%20the%20sum%20(F16)%20of%20the%206%25%20(C16)%20and%2023%25%20(E16)%20tax.%20So%2C%20whenever%20I%20enter%20the%20total%20value%2C%20I%20want%20that%20value%20to%20remain%2C%20because%20I'm%20sure%20that%20value%20(F16)%20is%20right.%26nbsp%3B%3C%2FP%3E%3CP%3E(I%20want%20the%20total%20(F16)%20dont%20change%20if%20I%20am%20to%20introduce%20it)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi, 

 

First, I'm sorry for my english (I used the google translator to help me)

i have three cells. a1 a2 and a3.

a3 is sum of a1+a2 

a3= a1 +a2, example 8 = 2+6,

 but I want also be possible when i put:

a1 = a2-a3 or

a2 = a1-a3

regardless where I put the values it calculates the third value

 

Thanks

18 Replies

@Ramsousa1986 

I am afraid that this doesn't make sense.

In the first place, a1 = a2-a3 and a2 = a1-a3 are not equivalent to a3 = a1+a2.

In the second place, what do you want to happen when you change one cell? Which cell should be kept the same, and which one should be changed?

For example, if I change cell A1, should I change the sum in A3, or should I keep the sum the same and change cell A2 so that A3 still equals A1+A2?

And if I change cell A3, should I keep A1 the same and change A2, or should I keep A2 the same and change A1?

@Twifoo 

While formulas would lead to circular references, it could be done using VBA - if it were clear what the OP actually wants.

@Ramsousa1986 

Can you explain what it is you trying to accomplish through this calculation?

 

At the moment, you are experiencing a circular reference in excel since all the cells are referencing one another and no clear "source"/number is manually inputted for a calculation.

@adversi and the rest people....

 

So, let me try explain again...

This is my Spreadsheet

 
 

image.png

columns:

N. Dev - is to identify the document (In this document (invoices and others) I have products with 6% tax, 23% tax and the total sum of the two tax.
I have to separate the products by tax)

 

6% - is tax produt (it's not important to what I want right now)

23% - is tax produt  (it's not important to what I want right now)

Total = 6% + 23% 

---------------//--------------

I have to enter the values of 6% and 23%, then the sum appears in column "F"

Image i put :   C17+E17 =F17; 5+6=11€;

 

but sometimes it would be easier for me if I put the value 6% and the total and  "excel" calculate the value 23%,; example F17 - C17 = E17; 11€ - 5€= 6€ 


or put the value of 23% and the total and calculate the value of 6% : example F17 - E17 = C17; 11€ - 6€ = 5€

regardless  where i places the values, he can calculate the the third value.

 

Thanks!

 

 

@Ramsousa1986 

This remains problematic.

Let's say you have entered 5 in C16 and 6 in E16. The sum 11 is calculated in F16.

Now you discover that C16 should actually have been 4.

How should Excel decide whether you want to update the total in F16 to 4+6 =10, or you want to adjust E16 to 11-4=7, keeping the total the same?

Do you have a decision rule for that?

@Ramsousa1986 

Thank you for clarifying. There are multiple ways to "automate" this issue to speed up your process. Are the documents you're using to count the number of products in a spreadsheet or are you manually counting? 

 

If this is already in a spreadsheet, then a function can be used rather than a complex nested formula to allow for dynamic cell inputs.

@adversi 

 

"Are the documents you're using to count the number of products in a spreadsheet or are you manually counting?" 

I dont need count the number of products. I just need to put the total of 6% products, and 23% products then, sum total of 6% and 23%. (i just need the value "€€€", i dont care if i have 1 or 23 products, for example). 

example: Invoice nº 2535 - have total tax 6% of 300€ and total 23% tax of 500€; Sum tax = 800€

 

Thanks

@Ramsousa1986 

Let me rephrase - is the source you're using for the input already in a spreadsheet?

@Hans Vogelaar 

 

Great question! 

Do you have a decision rule for that?

what can I say? in my documents I always have the sum (F16) of the 6% (C16) and 23% (E16) tax. So, whenever I enter the total value, I want that value to remain, because I'm sure that value (F16) is right. 

(I want the total (F16) dont change if I am to introduce it)

 

Thanks

 

 

No. Is a paper!

@Ramsousa1986 

Got it - looks like the nested IF function will be the best route.

 

Part 1: Formulas

 

Your formula(s) would be broken into three parts since you have three columns, which you can see in the example below (by each column): 

 

adversi_0-1607280409181.png

 

*you need to adjust the formula for the first case on your end

 

Column 1  ' Subtracting total from other integer

 

 

=IF(AND(F1<>"",G1<>""),G1-F1,"")

 

 

Column 2  ' Subtracting total from other integer

 

 

=IF(AND(G1<>"",E1<>""),G1-E1,"")

 

 

Column 3  ' Adding both integers

 

 

=IF(AND(E1<>"",F1<>""),E1+F1,"")

 

 

 

Part 2: Enable iterative calculation

 

To not get constant circular reference popups, you have to enable type of calculation in the Excel Settings.

 

Go to File > Options > Formulas > Enable iterative calculation

 

adversi_1-1607280546679.png

 

@adversi 

 

 

I lose the formula when I enter a value in the cell,
for example: if I put a value in cell E1 I lose the formula placed there. The same for the other cells

I have to protect the formula so it’s not erased when I put values there

(I used excel 2013)

@Ramsousa1986 

The point is to lose the formula. It is not possible to retain the formula and input your figure at the same time.

 

You drag down the formulas (before replacing with actual data) down to the last row you will need it for and input 2/3 numbers.

 

The remaining formula will calculate based on what is available, making the calculation dynamic.

@adversi 

 

I gess i need to use VBA 

@Ramsousa1986 

I don't think VBA is necessary - I'm not sure how it would work, that's better to ask for someone is more familiar.

@Ramsousa1986 

I don't think this is going to work, but you could try the following:

  • Right-click the sheet tab.
  • Select 'View Code' from the context menu.
  • Copy the code shown below into the worksheet module.
  • Switch back to Excel.
  • Save the workbook as a macro-enabled workbook (.xlsm).
  • Make sure that you allow macros when you open the workbook.
  • You'll find that there are situations in which the code can't decide what to do, so the sum will not be correct.
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Target.Row < 17 Then Exit Sub
    Application.EnableEvents = False
    On Error GoTo ExitHere
    Select Case Target.Column
        Case 3
            If Target.Value = "" Then
                Target.Offset(0, 3).Value = Val(Target.Offset(0, 2).Value)
            ElseIf Target.Offset(0, 2).Value = "" Then
                If Target.Offset(0, 3).Value <> "" Then
                    Target.Offset(0, 2).Value = Target.Offset(0, 3).Value - Target.Value
                End If
            Else
                Target.Offset(0, 3).Value = Target.Value + Target.Offset(0, 2).Value
            End If
        Case 5
            If Target.Value = "" Then
                Target.Offset(0, 1).Value = Val(Target.Offset(0, -2).Value)
            ElseIf Target.Offset(0, -2).Value = "" Then
                If Target.Offset(0, 1).Value <> "" Then
                    Target.Offset(0, -2).Value = Target.Offset(0, 1).Value - Target.Value
                End If
            Else
                Target.Offset(0, 1).Value = Target.Offset(0, -2).Value + Target.Value
            End If
        Case 6
            If Target.Offset(0, -3).Value = "" Then
                If Target.Offset(0, -1).Value <> "" Then
                    Target.Offset(0, -3).Value = Target.Value - Target.Offset(0, -1).Value
                End If
            ElseIf Target.Offset(0, -1).Value = "" Then
                Target.Offset(0, -1).Value = Target.Value - Target.Offset(0, -3).Value
            End If
    End Select
ExitHere:
    Application.EnableEvents = True
End Sub

@Hans Vogelaar 

@adversi 

@Twifoo 

 

Thank you for your help

for now I will give up this idea

 

Bye