Reputation: 23
Is there any formula or script to copy only values (not formulas) from one column to another?. I don't want to use CTRL + SHIFT + V because I need this to be automatic. For example:
Column A Column B
Value1
Value2
Value3
All the values of column A are calculated with an array formula, I need that everytime that column A has a new record the value passes to column B for ever, so if the value or formula in column A is deleted the copied value remains in column B, is it possible to do this?
Please any help!
Upvotes: 0
Views: 2530
Reputation: 430
You want to
If my understanding is correct, how about this answer? Please consider this as one of many possible ways of solving your problem.
Flow:
1. Get active sheet
2. Get active range (column)
3. Paste values into the range (column)
Sample Script:
function copyvalues() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('Sheet1');
const rg = sh.getRange(1,1,sh.getLastRow()); //Explore the various getRange functions
const va = rg.getValues(); //Explore Arrays if you are not familiar with it
va.forEach(function(r,i){
sh.getRange(i+1,2).setValues(r[0]).setNumberFormat('#,##0.00'); //Use setNumberFormat if you need to format your values with two decimal places and thousands separator (if not already done so)
})
}
Reference:
Upvotes: 1