Reputation: 741
I have a customer sheet and a invoice sheet
When I go to the invoice sheet D12 and I type the invoice ID that's located in the customer sheet, then I get all the data from some vlookups.
But what I want is this:
I click on a cell in the customer sheet where the invoice number is located in that row. I activate the test1 function and the invoice number should be changed in the invoice sheet D12.
But when I run this script I get this error:
TypeError: Cannot find function setActiveSheet in object Sheet
Does anyone know how to change the invoice D12 cell?
function test1() {
var ss = SpreadsheetApp.getActiveSheet();
var row = ss.getActiveCell().getRow();
var rowSource = ss.getRange(row, 8);
ss.setActiveSheet(spreadsheet.getSheetByName('Invoice'), true);
ss.getRange('D12').activate();
ss.getCurrentCell().setValue(rowSource);
}
Upvotes: 0
Views: 217
Reputation: 38435
The code examples on https://developers.google.com/apps-script and other places use ss
to hold a Class Spreadsheet object rather than a Class Sheet object.
Try replacing
var ss = SpreadsheetApp.getActiveSheet();
by
var ss = SpreadsheetApp.getActiveSpreadsheet();
Upvotes: 2