ホーム

Search for a specific character string from the range specified by GAS - Spreadsheet

String search with GAS

I would like to write a program that searches for a specific character string from the specified range of the spreadsheet and inserts a value next to it if it finds it.

Implementation

function myFunction() 
{
    var sheet = SpreadsheetApp.getActiveSheet(); 
    var lastRow = sheet.getLastRow();
     
      for(var i = 2; i <= lastRow; i++) 
      {
            if(  sheet.getRange(i, 1).getValue() === "Me")
            {   
              Logger.log(sheet.getRange(i, 1).getValue());
              sheet.getRange(i, 2, 1).setValue('I find you'); 
            }
      }
}

-ホーム

Copyright© off , 2020 All Rights Reserved Powered by AFFINGER5.