The code below adds a link to the cells in column A and this link, when clicked on, brings the user to cell E7, in another sheet. The column that now has the links set also has two adjacent columns (B and F) and whose row data should populate cells B19 and E7 in the destination sheet, when the user clicks on the link, on a specific row.
function addHyperlink(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var dataRng = ss.getSheetByName("Painel de Embarques").getRange(27, 1, ss.getLastRow(), 4).getValues();
var rngValues = [];//This is for getting only non-empty rows
for (var n = 0; n<dataRng.length; n++){
if (dataRng[n][1] != ''){
rngValues.push(dataRng);
}
}
var destSheet = ss.getSheetByName("Atualizar Embarque").getSheetId();
for (var a = 1; a < rngValues.length; a++) {
if (rngValues[a][1] != ''){
const fat = rngValues[a][1];
const stat = rngValues[a][5];
ss.getSheetByName("Painel de Embarques").getRange(27,1,rngValues.length,1).setValue('=hyperlink("https:sheetLink/edit#gid='+destSheet+'&range=E7";"Editar")');
}
}
}
The question is: How can I the script also populate destination cells like the following, when the user clicks on it? Row data column B would go on cell B19 on the destination sheet; Row data column F would go on cell E7 on the destination sheet.
Thank you!