getNextDataRange() from google Spreadsheatapp bug?

Asked

Viewed 54 times

0

Hello I came across the following situation: I just need to use a class method Selection from Google Spreadsheetapp in an enabled selection, but it is bringing the following bug:

ReferenceError: "Direction" não está definido.

But I’ve already looked at documentation on the subject and it follows that I still could not find the error.

Because Direction is not being recognized?

function ok() {
  var s1 = SpreadsheetApp.openById("PUT YOUR SPREADSHEET ID").getSheets()

  var s2 = s1[0]

  var s3 = s2.getRange("C4").activate()

  var s5 = SpreadsheetApp.getSelection().getNextDataRange(Direction.DOWN).getValues()

  var s4 = SpreadsheetApp.openById("PUT YOUR SPREADSHEET ID").getRange("C5:C8").setValues(s5)

  return s4

}

1 answer

1


The problem is that Direction is not global and is within the object SpreadsheetApp. Follow the corrected line:

var s5 = SpreadsheetApp.getSelection().getNextDataRange(SpreadsheetApp.Direction.DOWN).getValues()
  • Hi. Already enjoying the discussion: function ok() {
 SpreadsheetApp.openById("ID").setActiveRange("B2").activateAsCurrentCell();
 SpreadsheetApp.getSelection().getNextDataRange(SpreadsheetApp.Direction.FORWARD)
}
 for the second time when I will use Spreadsheetapp Object, my previous selection will be available?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.