I woke up this morning to find a program I made was encountering errors. After some testing I found the getActiveRange() function was no longer returning the correct values in my sheet.
I made a test sheet to troubleshoot the issue, and found that getActiveRange() is permanently returning the value of cell A1, rather than the highlighted cells. I know the sheet connection is fine because I had the program write the contents to another cell in the sheet and it is updating correctly.
Any Ideas on what needs to be changed? Did google break something?
const SHEET_ID = "abc123";
function onOpen(){
SpreadsheetApp.getUi()
.createMenu('Script Menu')
.addItem('Test Names', 'testNames')
.addToUi();
}
function testNames(){
SpreadsheetApp.flush();
var sheet = SpreadsheetApp.openById(SHEET_ID).getActiveSheet();
var range = sheet.getActiveRange();
var values = range.getValues();
var startRow = range.getRow();
Logger.log(values);
for (var i = 0; i < values.length; i++) {
sheet.getRange(i + 1, 5).setValue(values[i][0]);
sheet.getRange(i + 1, 6).setValue(values[i][1]);
}
}
The script should copy the highlighted values into neighboring columns. It does not do so.
Max Julius is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.