Reputation: 27
I need to go to specific cell that contains today's date, but .getRangeByName() or .getA1Notation() doesn't work. This is my script:
item1: function() {
var sheet = SpreadsheetApp.getActiveSheet();
var date = Utilities.formatDate(new Date(), 'GMT-5', 'dd/MM/yyyy');
var cell = sheet.getRangeByName(date).getA1Notation();
sheet.setActiveRange(cell);
},
Upvotes: 0
Views: 2063
Reputation: 201513
I believe your goal as follows.
var date = Utilities.formatDate(new Date(), 'GMT-5', 'dd/MM/yyyy');
in the active sheet using Google Apps Script.For this, how about this answer?
getRangeByName
cannot be used for searching values. In this case, I would like to propose to use TextFinder.function myFunction() {
var ss = SpreadsheetApp.getActive();
var sheet = SpreadsheetApp.getActiveSheet();
var date = Utilities.formatDate(new Date(), 'GMT-5', 'dd/MM/yyyy');
// I modified below script.
var ranges = sheet.createTextFinder(date).findAll().map(r => r.getA1Notation());
sheet.getRangeList(ranges).activate();
}
Upvotes: 1