Advertisement
Virajsinh

Google Sheet Last Edit Cell Focus

Aug 18th, 2020
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Google Sheet Last Cell Edit Focus
  2. -------------------------------------------------
  3.  
  4. function setTrigger() {
  5. var ss = SpreadsheetApp.getActive();
  6. ScriptApp.newTrigger("myFunction").forSpreadsheet(ss).onEdit().create();
  7. }
  8.  
  9. function myFunction() {
  10. var sheet = SpreadsheetApp.getActiveSheet();
  11. var sName = sheet.getName();
  12. var currentCell = sheet.getActiveCell().getA1Notation();
  13. UserProperties.setProperty("mySheetName", sName);
  14. UserProperties.setProperty("myCell", currentCell);
  15. }
  16.  
  17. function onOpen() {
  18. var lastModifiedSheet = UserProperties.getProperty("mySheetName");
  19. var lastModifiedCell = UserProperties.getProperty("myCell");
  20. SpreadsheetApp.getActiveSpreadsheet().getSheetByName(lastModifiedSheet).getRange(lastModifiedCell).activate();
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement