I have a series which is like 1,1,1,1,1,1,1,2,2,2,2,2,2,2...

I have filled 1(*8) times and 2(*8) times, how do I continue this series by drag-drop option in Google Sheets?

migrated from superuser.com Sep 5 '18 at 20:11

This question came from our site for computer enthusiasts and power users.


We need to develop a custom function for doing the required tasks.

/* _val is the number of series you want
*  you want 166 series of the number which is like 166*8
*/ the function will fill 1328 rows

function myFunction(_val) {

  var data = [];

  for(var x =1 ; x < _val ; x++){
    // here 8 is the number of times you want the number to repeat
    for(var l = 0 ; l < 8 ; l++){

  return data;

Points to be noted:

  1. You can return a multidimensional array like [[1,2] [4,5]] to fill up multiple columns at a time // here the result will be Cell A will have 1,4 and B will have 2,5

  2. You can't use setValue() in a custom function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy