|
- function test(){
- Application.ScreenUpdating = false
- let dataSource = Sheets("Sheet1").Range("b1:b" + Sheets("Sheet1").Cells(Rows.Count,2).End(xlUp).Row).Value2.flat().filter(v => v)
- let res = dataSource.reduce((p,c) => {
- if(c.includes(":")){
- let [k,v] = c.split(":")
- if (p[0].includes(k)){
- p[p["r"]][p[k]] = p[p["r"]][p[k]] ? p[p["r"]][p[k]] + "," + v : v
- }else{
- p[k] = p[0].push(k) - 1
- p[p["r"]][p[k]] = v
- }
- }else{
- p["r"] = p.push([c]) - 1
- }
- return p
- },[["项目名称"]])
- Sheets("Sheet2").Range("a8").CurrentRegion.ClearContents()
- Sheets("Sheet2").Range("a8").Resize(res.length,res[0].length).Value2 = res
- Application.ScreenUpdating = true
- }
复制代码 抽空认真的做了一下,一个循环搞定
|
|