-3

In a column, how can you make an alternate data? I mean for example I want to populate TI,TO for every each row in a column like this.

enter image description here

TYSM for Help

pnuts
  • 58,317
  • 11
  • 87
  • 139
Nardong Bagsik
  • 218
  • 6
  • 20

2 Answers2

2

A script seems overkill when:

=if(isodd(row()),"TI","TO")

copied down will achieve the same result (switch I and O if starting in an even numbered row) or simpler still just enter TO in a cell immediately below one containing T1, select the pair and drag the fill handle down.

pnuts
  • 58,317
  • 11
  • 87
  • 139
0

Here is a example:

function tito(){
  var sheet = SpreadsheetApp.getActiveSheet();
  var nb = 10;  // Number of row to insert
  var start = 2; // Row where it should start
  var col = 1;   // Colummn where it should append
  var range = sheet.getRange(start, col, nb);
  var array = [];
  for(var i = 0; i < nb; i++){
    if(isOdd(i) == 1)
      array.push(["TO"]);
    else
      array.push(["TI"]);
  }
  range.setValues(array);
}

 function isOdd(num) { return num % 2;} 
Pierre-Marie Richard
  • 1,914
  • 2
  • 19
  • 25