# Thread: Condition Check for the Current Cell

1. ## Condition Check for the Current Cell

Hello Friends,
Cell A1=1, A2=1, A3=A1*A2

When I change A1 Value and if it gives A3>previous value I would like to store the A1=A4
kindly guide me

Regards

2. ## Re: Condition Check for the Current Cell

Do you want to put the new A1 value in A4 or the previous A1 value?
What about A3 < A3 previous value - should A4 be cleared?

3. ## Re: Condition Check for the Current Cell

Originally Posted by footoo
Do you want to put the new A1 value in A4 or the previous A1 value?
What about A3 < A3 previous value - should A4 be cleared?
Cell A1=1, A2=1, A3=A1*A2

When I change A1 Value and if it gives A3>previous value I would like to store the A1=A4

like this

and like this

Kind Regards

4. ## Re: Condition Check for the Current Cell

You didn't advise what you want to happen if A3 is less than before.
Code:
```Private Sub Worksheet_Change(ByVal Target As Range)
Dim x#, y#
If Target.Address <> "\$A\$1" Then Exit Sub
Application.EnableEvents = False
x = [A1]
y = [A3]
Application.Undo
If [A3] < y Then [A4] = x
[A1] = x
Application.EnableEvents = True
End Sub```

5. ## Re: Condition Check for the Current Cell

Sorry dude, It should not change anything. only the A4 change if greater than previous.
and Is there possible that we can use formulas (like we use = in cell?)

PS:How to use this program with in excell?
oops. Got that. Rightclick., and view code
Kind Regards

6. ## Re: Condition Check for the Current Cell

I don't know a way to do it with a formula.

7. ## Re: Condition Check for the Current Cell

Dude, the calculation is not correct.
Here is example.,
type 68 in A1
type 10 in A2
Now the A3 will be 680 so this is current high value

and now change to A1 to 67
and A2 to 16 now the value of A3 is 1072 which is higher than previous it was

so the A4 must show now 67 but It shows 68

8. ## Re: Condition Check for the Current Cell

This is the first time you've mentioned that you also want to change A4 if A2 is changed - you previously only mentioned a change in A1,
Code:
```Private Sub Worksheet_Change(ByVal Target As Range)
Dim x#, y#, z#
Application.EnableEvents = False
x = [A1]
z = [A2]
y = [A3]
Application.Undo
If [A3] < y Then [A4] = x
[A1] = x
[A2] = z
Application.EnableEvents = True
End Sub```

9. ## Re: Condition Check for the Current Cell

Originally Posted by footoo
This is the first time you've mentioned that you also want to change A4 if A2 is changed - you previously only mentioned a change in A1,
Sorry brother, It's lack of my English knowledge. If I'd explained like this before you'd understand well.

10. ## Re: Condition Check for the Current Cell

bro, it need another extra thing.
If suppose I enter 500 in A1 and 22 in A2 the value of A3 is 11000 and the A4 is Now 500
and again If I enter 68 in A1 and 10 in A2 Now the A3 shows 680 and A4 is now 500
and now change to 67 in A1 and 16 in A2 now the value of A3 is 1072 the A4 value changed to 67
But the result I expect in A4 is still 500 (because we got higher value 11000 in A3 while we used that)

Kind Regards