1

I have the following block of code that I am using to insert a drop down box into one of my cells. I want to replace the A10 with a row number and column number.

So there are two things I would like to be able to do. Either

a> figure out a way to do SpreadsheetApp.getActive().getRange(1,10) or

b> if there's a way I can get the location of my cell using Excel like notation. What I mean by that is, if my cell A10 contains the value 'Test', i would like to figure out the cell details (A10) of where 'Test' resides in my Google spreadsheet. Either of them would help me.

var cell = SpreadsheetApp.getActive().getRange('A10');
var rule = SpreadsheetApp.newDataValidation().
           requireValueInList(['Yes', 'No'], true).build();
cell.setDataValidation(rule);
p0tta
  • 1,461
  • 6
  • 28
  • 49
  • Maybe you'd better check [this](http://stackoverflow.com/questions/10807936/how-do-i-search-google-spreadsheets?noredirect=1&lq=1), [this](http://stackoverflow.com/questions/19457371/find-value-in-spreadsheet-using-google-script), or similar questions. – Sangbok Lee Mar 03 '17 at 17:01

1 Answers1

-1
var cell = SpreadsheetApp.getActive().getRange('A10');

The above line should be:

var cell = SpreadsheetApp.getActiveSheet().getRange('A10');

or

var cell = SpreadsheetApp.getActive().getRange('Sheet1!A10');

or whatever the name of your sheet is.

Cooper
  • 59,616
  • 6
  • 23
  • 54
  • I don't know if you intended to answer my question but that's not what I am looking for. – p0tta Mar 04 '17 at 03:09
  • I was just pointing out an error in your code and suggesting two alternatives. – Cooper Mar 04 '17 at 04:02
  • 1
    So perhaps you wanted to know about the [getA1Notation()](https://developers.google.com/apps-script/reference/spreadsheet/range) function on the Ranges page of the documentation – Cooper Mar 04 '17 at 04:11