Hi All
I'm new to the site. Hopefully I have posted this properly!
In the file I'm working in, there are a series of cell into which the user can enter a value of their choice. These cells are all independent of each other so the value are also separate and independent of each other.
I wish for an message box to appear on the screen when a value in entered into a cell which is greater than the cell next to it. This I have managed. However I've been caught out by the fact there are a series of these cell. If the value in one cell is left above the threshold value every time a new number is entered the same message box appears. Even when the newly entered value is below the threshold value.
I'm not sure how to modify the below sub routine to accommodate this. I only want the message box to appear when the value entered into the cell at that time is greater than the threshold. Not the situation when one value higher up is above the threshold an then triggers the message.
Can someone advise how I can modify my coding?
Best Regards
Paul
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("L9") > Range("K9") Then MsgBox num & "Offered discount is greater than the permissible discount"
If Range("L12") > Range("K12") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L16") > Range("K16") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L21") > Range("K21") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L24") > Range("K24") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L28") > Range("K28") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L32") > Range("K32") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L35") > Range("K35") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L38") > Range("K38") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L41") > Range("K41") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L46") > Range("K46") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L49") > Range("K49") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L51") > Range("K51") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
End Sub
I'm new to the site. Hopefully I have posted this properly!
In the file I'm working in, there are a series of cell into which the user can enter a value of their choice. These cells are all independent of each other so the value are also separate and independent of each other.
I wish for an message box to appear on the screen when a value in entered into a cell which is greater than the cell next to it. This I have managed. However I've been caught out by the fact there are a series of these cell. If the value in one cell is left above the threshold value every time a new number is entered the same message box appears. Even when the newly entered value is below the threshold value.
I'm not sure how to modify the below sub routine to accommodate this. I only want the message box to appear when the value entered into the cell at that time is greater than the threshold. Not the situation when one value higher up is above the threshold an then triggers the message.
Can someone advise how I can modify my coding?
Best Regards
Paul
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("L9") > Range("K9") Then MsgBox num & "Offered discount is greater than the permissible discount"
If Range("L12") > Range("K12") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L16") > Range("K16") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L21") > Range("K21") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L24") > Range("K24") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L28") > Range("K28") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L32") > Range("K32") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L35") > Range("K35") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L38") > Range("K38") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L41") > Range("K41") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L46") > Range("K46") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L49") > Range("K49") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
If Range("L51") > Range("K51") Then MsgBox num & "Offered discount is greater than the permissible discount. Obtain Regional Commercial Director's approval"
End Sub