Condition Check for the Current Cell

treeppm

Board Regular
Joined
Jun 3, 2015
Messages
60
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
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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?
</previous>
 
Last edited:
Upvote 0
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
2JMrw.png


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

like this
2JMrx.png


and like this
2JMry.png


Kind Regards
 
Last edited:
Upvote 0
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
 
Upvote 0
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
 
Last edited:
Upvote 0
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
 
Last edited:
Upvote 0
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#
If Target.Address <> "$A$1" And Target.Address <> "$A$2" Then Exit Sub
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
 
Upvote 0
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.
 
Upvote 0
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
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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