0

The following script runs well on my Windows PC but on my phone, when I enter the date in Cell A1, it does nothing other than clear the cell. Is this a limitation of Google Sheets on a mobile or am I doing something wrong

function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet()
var sheet = ss.getActiveSheet();
var changedCell = sheet.getActiveCell().getA1Notation();

if(changedCell=="A1") {
  var columns = sheet.getMaxColumns();
  var theDay = new Date(sheet.getRange(1,1).getValue()).setHours(0,0,0,0);
  
  sheet.getRange("A1").setValue("");

  sheet.setActiveSelection("B1").activate;

  for (var i=2;i<columns; i++) {
    var workDate = new Date(sheet.getRange(3,i).getValue()).setHours(0,0,0,0);
    if (theDay === workDate) {
      sheet.getRange(4,i).activate();
      break;
    }
  }
} 
}
Robbo
  • 1
  • 3
  • What do you expect it to do? – TheMaster Feb 04 '22 at 08:39
  • Related: https://stackoverflow.com/questions/33373826/ – TheMaster Feb 04 '22 at 08:45
  • Thanks for your feedback. Yes, those links answered why my first attempt at writing a script failed "Avoid calls to get active: getActive() sheet, range or cell. These don't work in mobile or they return a default value like A1 in the first sheet for range." My Script, of necessity, needs to work with the active sheet and active cell. – Robbo Feb 05 '22 at 00:25
  • Re "What do you expect it to do?" I want a user to enter a date in cell A1 and have the Script find the column with that date in a cell on row 3 and display it. This is my first attempt at a Script. Works well on a PC. – Robbo Feb 05 '22 at 00:35

0 Answers0