Home > front end >  Copy only values to a different sheet not formulas
Copy only values to a different sheet not formulas

Time:11-29

I am making an invoicing sheet. I want all the fields in the invoice to be copied and logged into a different sheet every time after a invoice is generated.

I have used multiple formulas in the invoice sheet and when i try and copy i am getting an error. How do i only copy values here?

CodePudding user response:

If you want to get the values with formatting, use getDisplayValue(). If you just want the value of the cell, use getValue().

CodePudding user response:

Use getValues() to copy data (this function ignores formulas and only copies the values) and setValues() to paste them in the invoice

var ss = SpreadsheetApp.openById('123');
var data = ss.getSheetByName('123').getRange('A1:A2').getValues();
ss.getSheetByName('invoice').getRange('A1:A2').setValues(data);
  • Related