1
votes

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

2

2 Answers

4
votes

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.

2
votes

Dont have a spreadsheet at hand to try, but try =arrayformula(if(N:N=0;"N";"N"))