0
votes

I'm having trouble converting this code to GAS. I want a message box to appear if cell c54 is > than cell c56. Can someone help me? Thanks in advance.

Private Sub Worksheet_Change(ByVal Target As Range)

If Range("c54").Value > Range("c56").Value Then
MsgBox ("Maximum reached")
Target.Value = ""
End If

End Sub
1

1 Answers

1
votes

Try the below code...

function checkValues(){
  var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    if(ss.getRange("c54").getValue() > ss.getRange("c56").getValue()){
      Browser.msgBox("Maximum reached");
      ss.getRange("c56").clear(); // will clear the cell c56
    }
}