Hi,
using the website below:
I'm trying to make two check box buttons that will work in an Android application. I copied the code from the video and created two codes for the check box buttons in B3 and C3. The B3 check box is supposed to decrease the value in B2 by 1, and the check box in C3 is supposed to increase the value by 1. Both codes work separately, i.e. when the other one is not present. I would like them to work when entered into Apps Script at the same time. The screenshot below shows the Google sheet view.
Below is the code for both codes:
using the website below:
Below is the code for both codes:
VBA Code:
function counterMinus () {
let counterMinusSS=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("dz")
let counterMinusCell=counterMinusSS.getRange("B1")
counterMinusCell.setValue(counterMinusCell.getValue()-1)
}
function onEdit(){
let activeCellMinus = SpreadsheetApp.getActiveSpreadsheet().getActiveCell()
let reference=activeCellMinus.getA1Notation()
let sheetName=activeCellMinus.getSheet().getName()
let activeValueMinus=activeCellMinus.getValue()
if (reference == "B3" && sheetName == "dz" && activeValueMinus == true) {
counterMinus();
activeCellMinus.setValue(false)
}
}
VBA Code:
function counterPlus () {
let counterPlusSS=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("dz")
let counterPlusCell=counterPlusSS.getRange("B1")
counterPlusCell.setValue(counterPlusCell.getValue()+1)
}
function onEdit(){
let activeCellPlus = SpreadsheetApp.getActiveSpreadsheet().getActiveCell()
let referencee=activeCellPlus.getA1Notation()
let sheetNamee=activeCellPlus.getSheet().getName()
let activeValuePlus=activeCellPlus.getValue()
if (referencee == "C3" && sheetNamee == "dz" && activeValuePlus == true) {
counterPlus();
activeCellPlus.setValue(false)
}
}
Last edited: