|
- function test(){
- let arr = Range("a1:a" + Cells(Rows.Count,1).End(xlUp).Row ).Value2
- let k = 0 //上级flag
- let m = 3 //偏移值
- arr.forEach((v,i) =>{
- let s = v[0].substring(0,1)
- switch (s) {
- case "最" :
- arr[i][1+m] = "清单码"
- arr[i][2+m] = "M码","W码"
- arr[i][3+m] = "W码"
- break
- case "B" :
- k = i
- arr[k][1+m] = v[0]
- break
- case "M" :
- arr[k][2+m] = v[0]
- arr[i][1+m] = arr[k][0]
- break
- case "W" :
- arr[k][3+m] = v[0]
- arr[i][1+m] = arr[k][0]
- break
- case "Q" :
- arr[i][1+m] = v[0]
- arr[i][2+m] = v[0]
- arr[i][3+m] = v[0]
- break
- default:
- arr[i][1+m] = null
- arr[i][2+m] = null
- arr[i][3+m] = null
- }
- })
- Columns("H:AB").ClearContents()
- Range("h1").Resize(arr.length,arr[0].length).Value2 = arr
- Columns("H:AB").AutoFit()
- }
复制代码
|
|