AppScript - Find row of value while in a for-loop

Viewed 19

I have a spreadsheet with comma-separated values in one column. Sometimes there´s 4 values in one cell, sometimes it´s only 1, etc..

Example:

I need access to each of the values, so I push them into an array using:

  var allReportsLastRow = requestSheet.getLastRow();
  var allReports = requestSheet.getRange("F6:F"+allReportsLastRow).getValues();
  var searchArray = allReports.toLocaleString().split(",");

So far so good. My issue now is that I need access to the row where a value was found. Normally I would be able to get the row during the loop by getting the index + the row it started. This doesn´t work in this case, as there can be multiple values in one cell.

Got any suggestions?

1 Answers

What do you wish to do next?

function myfunk() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Your Sheet Name");
  const vs = sh.getRange("F6:F" + sh.getLastRow()).getValues().flat();
  vs.forEach(e => {
    let t = e.split(',');//now they are split what's next?
  })
}
Related