Type of Edition (Cell or Range) - OnEdit

25 views
Skip to first unread message

Sandra Patricia Perdigon Cortes

unread,
Nov 4, 2024, 2:56:37 AMNov 4
to Google Apps Script Community
Hello,
This is my scenario:
I have a Google Sheet with 4 dropdowns (all depended one from each other) and I need to clean the next ones when one is edited... this I already have it.

However it shouldn't work always, just when the user changes the value manually for a specific one. If the user copies and pastes the values  from another file (the 4 at same time) it shouldn't clean them.

This is the code I have so far... to control this I should know if it was edited a single cell or a range of cells, do you know how to know that?

function installedOnEdit(e) {

  if(e.range.rowStart!=1) {    
    // create dynamic and filtered dropdowns
    dropdown(e);
   
    var s = SpreadsheetApp.getActive();
    var r = s.getActiveCell();
 
    // clean depended dropdowns when a single cell is edited
   
    if( r.getColumn() == 1 ) {
      r.offset(0, 1).setValue('');
      r.offset(0, 2).setValue('');
      r.offset(0, 3).setValue('');
    }
    if( r.getColumn() == 2 ) {
      r.offset(0, 1).setValue('');
      r.offset(0, 2).setValue('');
    }
    if( r.getColumn() == 3 ) {
      r.offset(0, 1).setValue('');  
    }
  }
 }

Or maybe you have a best way to do it.
I appreciate your help.
Regards.


The information contained in this e-mail may be confidential. It has been sent for the sole use of the intended recipient(s). If the reader of this message is not an intended recipient, you are hereby notified that any unauthorized review, use, disclosure, dissemination, distribution or copying of this communication, or any of its contents, is strictly prohibited. If you have received it by mistake please let us know by e-mail immediately and delete it from your system. Many thanks.

 

La información contenida en este mensaje puede ser confidencial. Ha sido enviada para el uso exclusivo del destinatario(s) previsto. Si el lector de este mensaje no fuera el destinatario previsto, por el presente queda Ud. notificado que cualquier lectura, uso, publicación, diseminación, distribución o copiado de esta comunicación o su contenido está estrictamente prohibido. En caso de que Ud. hubiera recibido este mensaje por error le agradeceremos notificarnos por e-mail inmediatamente y eliminarlo de su sistema. Muchas gracias.


Keith Andersen

unread,
Nov 12, 2024, 6:35:08 PMNov 12
to google-apps-sc...@googlegroups.com
Might want to try this method...
https://youtu.be/p4bXhNH93sI?si=qt5FXmkfEQhJX0Cw

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/google-apps-script-community/90930384-4330-4b0a-af62-c482cefdfe59n%40googlegroups.com.


--

Passions: God, Family, Friends, Scripture, Data Management, Google Sheets + App Script, MS Access, Programing, sharing and much more.
Reply all
Reply to author
Forward
0 new messages