Someone could help me by giving me an example of a googlse script where if a user fills in information in 1 cell it will automatically delete what was before.
Let’s say that:
A:1 - Cart
But if anyone modifies it, be in the car again or the cell be clean
Look, I’ve been looking at the forum to see what I want to do, but it doesn’t work for me.
I tried to create a google script.
But I find that the way the trigger should work is onEdit however I have read that through Glide you must use onChange for the script to work.
//Poner número de columna que se va a modificar//
{
var range = e.range;
if(range.getColumn() == 4)
//Poner nombre de hoja y número de columna donde nos traerá la fecha//
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Simulador”).getRange(range.getRow() , 5).clearContent();
}
}
}
The previous one is the script I made but when I make a cell change from the App it is not edited, it is only edited if I do it myself by opening the google sheet. As I read and as I said you should use the onchange but I have no idea.
Firstly, rename your function. onChange should not be the name, let’s rename it to something like DeleteCell(e)
function deleteCell(e){
{
if(SpreadsheetApp.getActiveSpreadsheet().getSheetName() == "Simulador")
//Poner número de columna que se va a modificar//
{
var range = e.range;
if(range.getColumn() == 4)
//Poner nombre de hoja y número de columna donde nos traerá la fecha//
SpreadsheetApp.getActiveSpreadsheet().getSheetByName(“Simulador”).getRange(range.getRow(), 5).clearContent();
}
}
}
Then navigate to Edit > Current project’s triggers.
Try to do it with the tiggers that Google gives the problem is that they detect any change in the sheet and I just need that if we say A:1 is modified (they write something) the content in other specific cells is deleted like B:2 :B3 and B:4. I tried another type of programming but it didn’t work:
function DeleteCell(e){
if(e.changeType == ‘EDIT’ || e.changeType == ‘EDIT’){
A further demonstration to show that it works with Glide edit.
The script is:
function DeleteCell(e){
var r = e.source.getActiveRange();
var cell = r.getA1Notation();
if(cell == 'A2'){
var sheet = SpreadsheetApp.getActive().getSheetByName('Clear Content');
sheet.getRange('D2').clearContent();
}
else {
return;
}
}
You got to insert an IF clause that gets the cell notation as well, to prevent other cells’ changes affect the destination cell.
Yes, that’s exactly what I want, but the information would have to be sent from an app created by Glide.
Because that’s where the problem arises that the macro doesn’t work