Morning all
I was very kindly provided the code below which produces a message should the value of one cell (row 39) exceed the value of another (row 41) as users change data in a column. That works great.
What I would like to do is change it ever so slightly in that I would like the message to only appear if the user is "adding" data to the column rather than if they are removing. Ie if they remove data from the column but row 39 still exceeds row 41 no message is shown (as they are making the position better).
Is this possible at all?
The code I am using is below.
As always, any help appreciated.
Thanks
I was very kindly provided the code below which produces a message should the value of one cell (row 39) exceed the value of another (row 41) as users change data in a column. That works great.
What I would like to do is change it ever so slightly in that I would like the message to only appear if the user is "adding" data to the column rather than if they are removing. Ie if they remove data from the column but row 39 still exceeds row 41 no message is shown (as they are making the position better).
Is this possible at all?
The code I am using is below.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRange As Range
Dim col As Long
' Set range to apply this to
Set myRange = Range("E47:BB1000")
' Exit if more than one cell updated at a time
If Target.CountLarge > 1 Then Exit Sub
' Exit if cell updated is outside of designated range
If Intersect(Target, myRange) Is Nothing Then Exit Sub
'Get number of updated column
col = Target.Column
'Check to see if row 1 is greater than row 2 in that column
If Cells(39, col) > Cells(41, col) Then
MsgBox "This entry exceeds the agreed threshold, If you are adding leave please ensure this is has been agreed with your line manager", vbOK
'If answer = vbNo Then
Else
End If
End Sub
As always, any help appreciated.
Thanks