Home > OS >  copyTo google sheet appscript
copyTo google sheet appscript

Time:01-26

I'm very new to Javascript and Apps Script I'm looking to create a function that updates another sheet based on the date in a specific range of the active sheet. I run and there are no errors but it is not transferring the values from the active sheet to the named sheet "Feb".

Please help me see what I'm not seeing.

function updateYTD3() {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = ss.getSheetByName("January");
  const targetSheet = ss.getSheetByName("Feb");
  if (sheet && targetSheet) {
    if(sheet.getRange("A2:D32").getValues().length > 0){
      sheet.getRange("A2:D32").copyTo(targetSheet.getRange("C2"),{contentsOnly:true});
    }
  }
}

but with funcition Loop and copy range based on criteria

enter image description here

  • Related