|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub Main()
- Dim dArr, rArr, nRow&, H&, N&, K&, B As Boolean
- dArr = Sheet1.[A1].CurrentRegion
- nRow = WorksheetFunction.Sum(WorksheetFunction.Index(dArr, 0, 3))
- ReDim rArr(1 To nRow, 1 To 3)
- H = 0: K = 0
- For i = 2 To UBound(dArr)
- B = dArr(i, 1) <> dArr(i - 1, 1)
- If B Then H = H + 100
- For j = 1 To dArr(i, 3)
- K = K + 1
- If B Then N = H: N = N + j Else N = N + 1
- rArr(K, 1) = dArr(i, 1)
- rArr(K, 2) = dArr(i, 2)
- rArr(K, 3) = N & "号"
- Next j
- Next i
- With Sheet1
- .Range("E1").CurrentRegion.Clear
- .Range("E1").Resize(1, 3) = Array("地址", "覆盖设备", "户号")
- .Range("E2").Resize(nRow, 3) = rArr
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|