I'm trying to make this simple function where I get the range & value I want to fill from the prompt response (so basically autofill given range with given value). But I get 'Exception: Range not found'. How can I use the response from prompt to work as range?
function myFunction(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ui = SpreadsheetApp.getUi ();
var response = ui.prompt("Enter Range:",ui.ButtonSet.OK_CANCEL);
if(response.getSelectedButton() == ui.Button.OK){
var inputvalue = ui.prompt("Set Value:",ui.ButtonSet.OK_CANCEL);
var givenvalue = inputvalue.getResponseText();
ss.getRange(response.getResponseText).setValue(givenvalue)
}else if(response.getSelectedButton() == ui.Button.CANCEL){
}
}
Exception: Range not found, is due togetRange(response.getResponseText). In this case, the method ofgetResponseTextis not run. Please add()likess.getRange(response.getResponseText()).setValue(givenvalue), and test it again. I thought that there might be some duplicated questions in this case. But I couldn't find them. I apologize for this.