Pop up message if the value resulted from formula is higher than a certain value

  • [xpost][/xpost]


    https://www.mrexcel.com/board/…-a-certain-value.1195014/


    Hello,


    I have a file were each row coresponds with food choices from the catering firm, for a certain employee , and on the same row in BR3 there is the calculated total ammount based on the food they choose in the cells (D3: BQ3).


    I want a pop up message to be displayed if the value calculated in BR3 is greater than 116.


    Also i want to replicate this pop up for each row in the table so the range of cells, were the formula with total ammount is , will be B3:B67.


    I tried data validation by choosing Allow: Whole number->Greater than->Minimum:116 or Custom -> Formula:BR3>116


    Also if this works i whant to protect from editing the cells that calculate the total ammount, if this information is helpful in a vba code.


    Thank you.

  • Hello,


    I attached the file.


    ("Sa1,Mz1,Va1") are codes for food dishes and if you fill in 1 in the cell next to the food code column, it will calculate the price, for each day and the total days of the week in the BR column.


    I already have a data validation criteria + a vba code to highlight the cell and column in each cell selected.


    Thank you.

  • Try this code in the code for the sheet:


    Code
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B3:BJ67")) Is Nothing Then
    If Range("BR" & Target.Row) > 116 Then
    MsgBox "over"
    ActiveSheet.Unprotect Password:="PW"
    Range("B" & Target.Row & ":BJ" & Target.Row).Locked = True
    ActiveSheet.Protect Password:="PW"
    End If
    End If
    End Sub


    let me know if it does what you are after.

  • Try this code in the code for the sheet:


    Code
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B3:BJ67")) Is Nothing Then
    If Range("BR" & Target.Row) > 116 Then
    MsgBox "over"
    ActiveSheet.Unprotect Password:="PW"
    Range("B" & Target.Row & ":BJ" & Target.Row).Locked = True
    ActiveSheet.Protect Password:="PW"
    End If
    End If
    End Sub


    let me know if it does what you are after.

    Thank you so much.


    It's exactly what i wanted to achieve.


    Have a nice day.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!