Question

All this function intended to do is paste value the cell which the cursor is on. Can't get it to paste value

function fix_values(){

  var ss = SpreadsheetApp.getActiveSpreadsheet()
  var sheet = ss.getSheetByName('Time')
  var cell = sheet.getActiveCell()
  var value = cell.getValue()
  cell.setValue(value)
  cell.setFontColor('blue')
  cell.setNumberFormat("m/d/yy hh:mm")
  Logger.log(value)

}

what am I doing wrong?

Was it helpful?

Solution

Have you used the debugger to check what each line is returning?

I suspect that sheet.getActiveCell() is returning cell A1 no matter which cell is active. It's been a known issue.

See Issue 3496 Try the workarounds suggested at #23 and #41 or Issue 3110 workaround at #2

OTHER TIPS

The issue with the wrong notation for getActiveCell() and derivatives happens if the browser session gets lost. To keep it going again just close the editor tab, reload the spreadsheet and open the script editor from there again. That should make sure that both are having the same session.

Worked for me all the time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top