1

With the following function:

function updateCells() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var spreadsheetSummary = ss.getSheetByName('Summary');
  const range = spreadsheetSummary.getDataRange()
  const values = range.getDisplayValues()
  const transposeCheck = values[0].map((_, iCol) => values.map(row => row[iCol]).some(cell => cell))
  var countBoolean = transposeCheck.filter(Boolean).length
  var spreadsheetCommunityGroups = ss.getSheetByName('Community Groups');
  var cellValueCommunityGroups = spreadsheetCommunityGroups.getRange('A12').getValue();
  var summaryCommunityGroups = 'B'+countBoolean++
  spreadsheetSummary.getRange(summaryCommunityGroups).setValues(cellValueCommunityGroups);
}

I receive error

Exception: The parameters (number) don't match the method signature for SpreadsheetApp.Range.setValues.

1

1 Answer 1

1

Please try this:

function updateCells() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var spreadsheetSummary = ss.getSheetByName('Summary');
  const range = spreadsheetSummary.getDataRange()
  const values = range.getDisplayValues()
  const transposeCheck = values[0].map((_, iCol) => values.map(row => row[iCol]).some(cell => cell))
  var countBoolean = transposeCheck.filter(Boolean).length + 1
  var spreadsheetCommunityGroups = ss.getSheetByName('Community Groups');
  var cellValueCommunityGroups = spreadsheetCommunityGroups.getRange('A12').getValue();
  var summaryCommunityGroups = 'B'+countBoolean
  spreadsheetSummary.getRange(summaryCommunityGroups).setValue(cellValueCommunityGroups);
}
3
  • Thanks, Jacob, I need var summaryCommunityGroups = 'B'+countBoolean++ - I want the data placed in the next column over, hence the ++.
    – Steve
    Mar 31, 2021 at 3:29
  • That's why var countBoolean = transposeCheck.filter(Boolean).length + 1 Mar 31, 2021 at 7:08
  • @Steve not sure if my message can across.... Mar 31, 2021 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.