GAS sorting does not work: TypeError: Function getRange not found in object 1680.

Asked 2 years ago, Updated 2 years ago, 49 views

I get an error when I try to sort below. Why?

TypeError—Function getRange not found on object 1680.
  (line 5, file "Original 2") Do not display
function A(){
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var origin=spreadsheet.getSheetByName('Original 2');
  var origin_last_row = origin.getLastRow();
  origin_last_row.getRange(2,1,origin_last_row-1).sort([1,2,12]);
}

google-apps-script

2022-09-30 14:56

1 Answers

The origin.getLastRow() return value is Integer type (last line number), so there is no getRange() method.

This post was posted as a community wiki based on @metropolis' comments.


2022-09-30 14:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.