• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automate result in 3 cells, result depend of either of other 2 cells

nagovind

Member
Dear All,
Kindly refer to the below requirement. The user will enter input in any 2 of the cells. Based on those inputs from other cells 3rd cell will result as per the formula as listed. Is it possible to get this done In excel VBA? Kindly do the needful as necessary.
Regards
Narayan Govind
77752
 

Attachments

  • Toggle inputs.xlsm
    11.9 KB · Views: 1
See attached.
If you have numbers in all 3 cells G15, G17 & G19 and you change one of them no calculation will be done because although it's safe to assume that the cell you've just changed you want to keep, it can't know which of the other two cells you want to be changed. So the way to say which cell you want to change is by deleting its contents, when immediately that cell will be calculated.
Calculation will only happen if there are two numbers and one non-numeric cell amongst the three cells.
 

Attachments

  • Chandoo47550Toggle inputs.xlsm
    19.1 KB · Views: 1
p45cal
Thank you very much for your efforts and reply with an example
If I provide input in any of the 2 cells and if I press the DELETE key in the required result cell then results are displayed
If the same is automated like if the user KEYED IN any of the 2 cells the 3rd cell is to be deemed as to press DELETE key to get the answer in that cell. In this way is it possible to count the event whether the user has entered the data in any of the 2 cells so that for the 3rd cell we can do something
Kindly do the needful
 
This is going to be a very different approach.
In the attached, the macro tries to remember (by using STATIC variables) the 2 most recently adjusted values. This introduces some limitations:
  • After opening the file (or resetting the vba project) at least 2 of the cells will need to be adjusted before any calculation is even attempted.
  • It calculates only when one cell is altered; altering more than one of the 3 cells at once (eg by selecting them all and deleting, or by copy/pasting multiple cells from elsewhere) results in no attempted calculation.
I've added a few temporary lines of code to help testing which reports which cell is which in the cells to the right of the target cells:
  • * means nothing changed yet
  • last means it's the last cell changed
  • last2 means it's the second to last cell changed
  • result means it's the calculated value.
See the comments in the code about what to disable when you've finshed testing.

The code is messy; I haven't tried to streamline it or improve the algorithm/logic.
 

Attachments

  • Chandoo47550Toggle inputs.xlsm
    21 KB · Views: 1
Back
Top