# Equation HELP Needed

#### msqlh

##### New Member
Hello.
I am trouble creating the an equation to add to my excel spreadsheet. Can you help? I having the most part creating all the following steps into one working equation. This is what I am looking for the equation to do:

Cell information- G2= 38; H2 = 60; J2 = 3

First, take cell G2 subtract from H2 (=G2-H2)

Second, take the total of G2-H2 and divide it by H2 (side note to accomplish, I did change the "Iteration")

Third, if the total of the 2nd step is greater than 2, but less than 3 (which would be 2) subtract 2 from cell J2

Fourth, place the total of the 3rd step into L2

### Excel Facts

Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I believe the best (if not the only way), would be to use code. Is that an option??
lenze

I believe the best (if not the only way), would be to use code. Is that an option??
lenze

Hello Lenze.
It could be an option? Are you suggesting that I use a Marco? If so, where would I start? Or how would it be accomplished?

Hello Lenze.
It could be an option? Are you suggesting that I use a Marco? If so, where would I start? Or how would it be accomplished?
Yes, a macro and we can start at square 1.
1. How are the values in G2 and H2 and J2 entered?
2. Do you also want this to apply to other rows?

lenze

your third condition conclusion is faulty
Third, if the total of the 2nd step is greater than 2, but less than 3 (which would be 2)

Untrue that the answer would be 2.

If it is greater than 2 AND Less than 3 THEN it has to be a number between 2.01 and 2.999

Thanks Lenze, the numbers are already entered. It's just a matter of performing the task mentioned in my question post. Also, Nbrcrunch was able to catch an error in the third step. Where do I begin with Macro?

After rereading your OP, I think you just need a formula in L2. Something like
Code:
``=IF(((G2-H3)/H2>=2)*((G2-H2)/H2<=3),J2-2,"")``
If that's not correct, post back and I will look at some code.
lenze

Thanks for the equation, but it didn't work correctly. Any other suggestions?

A minor typo in the front, did you fix it...Change the red to H2

=IF(((G2-H3)/H2>=2)*((G2-H2)/H2<=3),J2-2,"")

Edit the typo and try it again. Should be
Rich (BB code):
``=IF(((G2-H2)/H2>=2)*((G2-H2)/H2<=3),J2-2,"")``

lenze

Replies
1
Views
252
Replies
5
Views
194
Replies
5
Views
914
Replies
3
Views
369
Replies
2
Views
407

1,203,472
Messages
6,055,612
Members
444,803
Latest member
retrorocket129

### 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.

### Which adblocker are you using?

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

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