Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to JS. Working with it in goog

Status
Not open for further replies.

gmart

Programmer
Jul 1, 2017
19
US
New to JS. Working with it in google sheets. For some reason, i can't get the nested if to filter out at the bottom. code is not finished. the log is at the very bottom. it should only log 4 times. Please tell me that JS in Google sheets is not that flaky.


JavaScript:
function loopsearch(){
  //looking for 'find me'
  var app = SpreadsheetApp;
  var str = "Team Name:";
  var strcell = "";
  var icount = 0; //counts number of team name instances in column A of Breakdown sheet
  var irowstart = 0;//starting row # for personnel names in team
  var inamecount = 0;//number of names for a team
  var i2 = 0;
  var i3 = 0;
  Logger.clear();
  //files will be built one team at a time then irowstart and inamecount will be reset
  //  Logger.log("Start here");
  //active sheet
  var activeSheet = app.getActiveSpreadsheet().getActiveSheet();
  
  
//loop will add 5 to cell with existing values   
  for(var i=1;i<1000;i++){
  var sCell = activeSheet.getRange(i+0,1).getValue();

  strcell = sCell;
  i2 = strcell.indexOf("Team")>=0;
  
//  Logger.log("i2 = "+ i2);
  if (strcell);{
    if (strcell.indexOf("Team")>=0);
    { 
        icount++;
        Logger.log(i2+"  "+true);
        
        irowstart = icount;

   //     Logger.log("inside if 2 = " + icount);
     }
     }
    }
  }

[17-10-30 17:05:01:659 EDT] false true
[17-10-30 17:05:01:661 EDT] false true
[17-10-30 17:05:01:663 EDT] false true
[17-10-30 17:05:01:665 EDT] true true
[17-10-30 17:05:01:667 EDT] false true
[17-10-30 17:05:01:669 EDT] false true
[17-10-30 17:05:01:670 EDT] false true
[17-10-30 17:05:01:672 EDT] false true
[17-10-30 17:05:01:674 EDT] false true
[17-10-30 17:05:01:676 EDT] false true
[17-10-30 17:05:01:677 EDT] false true
[17-10-30 17:05:01:679 EDT] false true
[17-10-30 17:05:01:680 EDT] false true
[17-10-30 17:05:01:682 EDT] false true
[17-10-30 17:05:01:683 EDT] false true
[17-10-30 17:05:01:685 EDT] false true
[17-10-30 17:05:01:687 EDT] false true
[17-10-30 17:05:01:689 EDT] false true
[17-10-30 17:05:01:691 EDT] false true
[17-10-30 17:05:01:692 EDT] false tru
 
This line

if (strcell.indexOf("Team")>=0);

didn't work, tried:
i2 = strcell.indexOf("Team")>=0;
if (i2==true);

Same log

Thank you for your help.
 
I got it. Took the ';' off the if(); condition area.

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top