-1

How do I make something that sends values from specific cells in a google sheet (say SHEET 1) to another sheet (say SHEET 2)? Can I make a menu button or something that would help me do that? Also, if possible, can I give the PDF link of SHEET 1 into the same row as the values from it under a different column? How do I go about writing the script?

gg0wwrr1
  • 21
  • 6

1 Answers1

0

Takes data from select cells on one sheet and moves to another sheet as a column

function makerglistacolumn() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Sheet1");
  const osh = ss.getSheetByName('Sheet2');
  const rl = sh.getActiveRangeList();
  let vo = [];
  rl.getRanges().forEach(r => {
    let vs = r.getValues().flat();
    Logger.log(JSON.stringify(vs));
    vs.forEach(e => vo.push([e]));
  });
  Logger.log(JSON.stringify(vo));
  osh.getRange(1, 1, vo.length, 1).setValues(vo);
}

Select the cells on Sheet1 using mouse and control key and execute function to move them to column1 of Sheet2

Here's the menu button:

function yourmenu() {
  SpreadsheetApp.getUi().createMenu("YourTools")
  .addItem("Move Data","makerglistacolumn") 
  .addToUi()
}

function onOpen() {
  yourmenu();
}
Cooper
  • 59,616
  • 6
  • 23
  • 54