0
votes

I have several cells in the same column and I want to check if they are empty.

In case there is any empty cell, add the following text ...

In case there is no empty cell, ignore ...

For some reason, I can't get it to return the value of the cells. The command editor tells me the following error:

TypeError: rangoCantidadNumeros.getValues is not a function

This is my code:

function placeholder_celdas(){

  const libro = SpreadsheetApp.getActiveSpreadsheet();
  var hoja = spreadsheet.getSheetByName('Ajustes'); 
  var rangoCantidadNumeros = hoja.getRangeList(['D10', 'D17', 'D24', 'D31', 'D38', 'D45', 'D52']);
  //var rangoValues = rangoCantidadNumeros.getValues();

  if ( rangoCantidadNumeros.getValues() == 0 ) {
    rangoCantidadNumeros.setValue("Escribe aquí la cantidad de números que quieres que tenga tu referencia. Ej: 6");
  } else {
     ''     
  }

}

I've been reviewing the code since yesterday, trying alternatives, but I always have problems with .getValue() and .getValues ​()

In the end, here I am, asking for help to see if an expert in the field could enlighten me.

Thank you very much

1

1 Answers

2
votes

getRangeList returns a RangeList not a Range.

You want to do something like this (not tested):

var ranges = rangoCantidadNumeros.getRanges(); // Gets a `Range[]`.
for (var range in ranges) {
  if (ranges[range].getValue() == 0) //...
}

References: