Reputation: 183
I have tried to push a value called "ticker" into a Google App Script Array:
ticker = name_cell.offset(0, i).getDisplayValue();
i.e. a Range object with two methods behind, which supposedly return a value. I think.
As I push such tickers into an Array, may I know whether I am actually pushing a value (which is what I wanted to do) or am I pushing the whole bulk of object.method.method syntax into the Array (which I suspected so)?
I am asking this because I suspect it may be the later case and problem occurs. In array output I was given undefined as array values, even when I know the value being hold in ticker is correct.
May I know what I should do in such a case?
Code As Provided in Comment Below:
var ss = SpreadsheetApp.openById("something");
var sheet = ss.getSheetByName("PASTEVALUE")
var crossup = [];
var i;
var name_cell;
var cross_up_cell;
cross_up_cell = sheet.getRange(2, 1);
for (i = 1; i <= 12; i++)
{
var ticker;
var value1;
ticker = name_cell.offset(0, i).getDisplayValue();//name_cell undefined
value1 = cross_up_cell.offset(0, i).getDisplayValue();
if (value1=="YES")
{
crossup.push(ticker)};//extraneous closing bracket here
}
Upvotes: 0
Views: 212
Reputation: 64100
getDisplayValue is a single value. Not an array. This is the documentations description. getDisplayValue() String Returns the displayed value of the top-left cell in the range.
Upvotes: 1