您好如何使用陣列函式獲取重復的增量數字。
下圖中的示例,如果我們在整A行中搜索一個單詞,如果有任何重復,它將在 中添加數字B。

uj5u.com熱心網友回復:
嘗試
=arrayformula(if(A1:A="",,
A1:A&if(countif(A1:A,A1:A)=1,,
"-"&text(countifs(A1:A,A1:A,row(A1:A),"<="&row(A1:A)),"00"))))

要么...
=A1&if(countif(A$1:A,A1)=1,,
"-"&text(countif(A$1:A1,A1),"00"))
......和拖累。

uj5u.com熱心網友回復:
計算重復項
function countdups() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Sheet0");
const vs = sh.getRange(1,1,sh.getLastRow(),2).getValues();
let uA = [];
let obj = {pA:[]};
vs.forEach(r => {
if(!~uA.indexOf(r[0])) {
uA.push(r[0]);
obj[r[0]] = 1;
obj.pA.push(r[0]);
} else {
obj[r[0]] = 1;
}
});
let vo = obj.pA.map(p => [`${p}-${obj[p]}`]);
sh.getRange(1,2,vo.length,1).setValues(vo);
}
| COL1 | COL1-1 |
|---|---|
| 7 | 7-2 |
| 6 | 6-1 |
| 9 | 9-1 |
| 11 | 11-3 |
| 16 | 16-1 |
| 4 | 4-1 |
| 15 | 15-1 |
| 19 | 19-3 |
| 11 | 2-1 |
| 2 | 10-3 |
| 10 | 18-1 |
| 11 | 5-1 |
| 10 | 0-1 |
| 18 | |
| 19 | |
| 19 | |
| 10 | |
| 5 | |
| 0 | |
| 7 |
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/431154.html
上一篇:表格腳本-根據背景顏色清除單元格
