Advertisement
Lodscripts

20190619 JescanellasScript 3 occurrences 2nd

Jun 19th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Jescanellas 2nd modification not working
  2.  
  3.  
  4. function numcharsbetweenocc2and3ofApple() {
  5.  
  6. var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet4");
  7.  
  8. var string1 = sheet.getRange(2, 2).getValues().toString();
  9.  
  10.  
  11. var apple_length1 = "apple".length;  
  12. var first_apple1 = string1.indexOf("apple") + apple_length1;
  13. var second_apple1 = string1.indexOf("apple", first_apple1);
  14. var third_apple = string1.indexOf("apple", second_apple1);
  15.  
  16.  
  17. var result1 = third_apple - second_apple1;
  18.  
  19. if (string1 !== "") {
  20.       sheet.getRange(2, 3).setValue(result1);
  21.     }  
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement