0

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
itzmurd4
  • 663
  • 10
  • 25
Hulten
  • 9
  • 2

1 Answers1

1

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
    }
}
Ritesh Nair
  • 3,327
  • 1
  • 17
  • 24
  • Thanks, it works great :) Only thing I miss is that I would like the code to delete what was last typed, is that possible? – Hulten Aug 03 '17 at 20:57