Advertisement
Lodscripts

20190619 JescanellasScript

Jun 19th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Jescanellas Script
  2.  
  3. //https://stackoverflow.com/a/56664841/10789707
  4.  
  5. //https://docs.google.com/spreadsheets/d/1v6jTVZQY-5aneKUhwpMqurnVZelUsnQFNQueFFH0yA4/edit?usp=sharing
  6.  
  7.  
  8.  
  9. function numcharsbetweenocc1and2ofApple() {
  10.  
  11.  
  12. var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet4");
  13.  
  14. var string = sheet.getRange(1, 2).getValues().toString();
  15.  
  16. var apple_length = "apple".length;  
  17. var first_apple = string.indexOf("apple") + apple_length;
  18. var second_apple = string.indexOf("apple", first_apple);
  19.  
  20.  
  21. var result = second_apple - first_apple;
  22.  
  23.  
  24. if (string !== "") {
  25.       sheet.getRange(1, 3).setValue(result);
  26.     }  
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement