Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets GoogleSheets:基于单元格的COUNTA重复一行,ARRAYFORMULA_Google Sheets_Array Formulas - Fatal编程技术网

Google sheets GoogleSheets:基于单元格的COUNTA重复一行,ARRAYFORMULA

Google sheets GoogleSheets:基于单元格的COUNTA重复一行,ARRAYFORMULA,google-sheets,array-formulas,Google Sheets,Array Formulas,我有一张如下的桌子。该表会不时更新,因此不知道确切的行数: +--+-------+-------------+ |a |红色| 1,1,1,| +--+-------+-------------+ |b |绿色| 2,2,| +--+-------+-------------+ |c |蓝| 3| +--+-------+-------------+在脚本编辑器中粘贴此脚本 /** * Splits the array by commas in the column with g

我有一张如下的桌子。该表会不时更新,因此不知道确切的行数:

+--+-------+-------------+
|a |红色| 1,1,1,|
+--+-------+-------------+
|b |绿色| 2,2,|
+--+-------+-------------+
|c |蓝| 3|

+--+-------+-------------+
在脚本编辑器中粘贴此脚本

    /** 
 * Splits the array by commas in the column with given index, by given delimiter
 * @param {A2:B20}  range Range reference
 * @param {2}  colToSplit Column index
 * @param {","}  delimiter Character by which to split
 * @customfunction
 */


function advancedSplit(range, colToSplit, delimiter) {
    var resArr = [], row;
    range.forEach(function (r) {
        r[colToSplit-1].replace(/(?:\r\n|\r|\n)(\d|\w)/g,", ").split(delimiter)
            .forEach(function (s) {
                row = [];
                r.forEach(function (c, k) {               
                   row.push( (k === colToSplit-1) ? s.trim() : c);
                })
                resArr.push(row);
            })
    })
     return resArr.filter(function (r) {
        return r.toString()
            .replace(/,/g, "")
    })
    }
然后在电子表格中将此脚本用作自定义公式

=advancedSplit(E2:G, 3, ",")

我希望这有帮助?

@Ogggrrr如果这回答了您的问题,请接受答案: