'Google apps script - Auto Fill Column?
I've just learnt about arrayformula and continue for keeping formulas into new rows, now im trying to get a single string to copy into new rows "N". How can I achieve this?
Basically, i've got some columns with formulas that are copied down using array formula, i've tried to use this to copy "N" into a column which needs to be pre-filled with "N" how it has not work, is there any other ways I can achieve this?
Overall I'm just asking is there a way to fill a single column with the letter "N" using either a formula or a script? If yes how?
Many thanks
Solution 1:[1]
Don't have a spreadsheet at hand to try, but try
= arrayformula(if(N:N=0;"N";"N"))
Solution 2:[2]
The most efficient way using a script would be like this :
function myFunction() {
var s = SpreadsheetApp.getActiveSheet();
var col = [];
for(var n=0 ; n<s.getMaxRows();n++){
col.push(['N']);
}
s.getRange('N:N').setValues(col); // write data in any column, N in this example :-)
}
It creates a 2D array with the right value and size and writes it on the sheet in one single step.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Anant Kumar Singh |
Solution 2 |