Adding blank rows in a set of data in Google Sheets

孤街醉人 提交于 2019-12-12 06:38:30

问题


I have a set of data. What i am looking forwards is to add 2 blank rows after each set of 3 values like this

Hope to get help in getting this solved.

you can find the sample google sheet here : https://docs.google.com/spreadsheets/d/11nMvUWn3xcTfxlk4v30KruPr03HSheMk1jrxZPpJ_p4/edit?usp=sharing

Thanks

Shijilal


回答1:


Solution:

  • IF it's the third row, Add 3 bunnies separated by a space, else keep the values as it is
  • JOIN them all and SPLIT by a bunny and TRANSPOSE

Sample:

=ARRAYFORMULA(TRANSPOSE(SPLIT(TEXTJOIN("🐇",1,IF(MOD(ROW(A2:A16),3)=1,A2:A16&REPT("🐇 ",3),A2:A16)),"🐇")))



回答2:


Some time ago, I created this custom function that may help you. I changed it slightly to meet your requirement and added it to the script editor.

function rowsBetween(range, s, rowsWithData, text) {
var n = [],
    a = [],
    i = 0;

while (i < s) {
    a.push(text
    )
    i++;
}
range.forEach(function(r, i) {

    n.push(r);
     if((i + 2) % rowsWithData == 1) {
    a.forEach(function(x) {
        n.push(x);
    });
    }
});
return n;
}

This script will allow you to enter in the spreadsheet this (custom) formula (see also cell E2)

=rowsBetween(A2:A16, 2, 12,)

See if that works for you?



来源:https://stackoverflow.com/questions/52964418/adding-blank-rows-in-a-set-of-data-in-google-sheets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!