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:
Code:
Private Sub Worksheet_Change


Dude, is there any way that when ever we change A1 value it automatically can set the A2 value to 1? (only when we change the A1 value).
after that we can change the A2 as much as we want.

Kind Regards
 
Last edited:
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
from that code you gave I would like to tweak like this.
When I enter the value in A1 and press enter 1st it should change the A2 value to 1 then the cursor should go to A2 when the cursor focusing on A2 it should calculate current A1*A2 value and give it to A3. and If I change the A2 and press enter It should recalculate (A1*A2) and cursor should focus on A1( The rest of the thing are same, which is storing A3 higher value in B3, and If the current value of A3 is higher than previous value then storing A1 value in A4) Past 3 hrs I tried all the way by searching in the internet but could not get succeed :confused:
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" And Target.Address <> "$A$2" Then Exit Sub
Application.EnableEvents = False
If Target.Address = "$A$1" Then
    [A2] = 1
    [A2].Select
ElseIf Target.Address = "$A$2" Then: [A1].Select
End If
If [A3] > [B3] Then
    [A4] = [A1]
    [B3] = [A3]
End If
Application.EnableEvents = True
End Sub
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$A$1" And Target.Address <> "$A$2" Then Exit Sub
Application.EnableEvents = False
If Target.Address = "$A$1" Then
    [A2] = 1
    [A2].Select
ElseIf Target.Address = "$A$2" Then: [A1].Select
End If
If [A3] > [B3] Then
    [A4] = [A1]
    [B3] = [A3]
End If
Application.EnableEvents = True
End Sub
WooooWwwwwww. Exactly working., Yo dude., Feeling so much happy.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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