常见字典用法集锦及代码详解(全) - 蓝桥玄霜 - 图文

实例12 复杂报表汇总

r2 = r2 + 1

ReDim Preserve Arr2(1 To r2) Arr2(r2) = ii End If Next

For ii = 1 To r2 If ii <> r2 Then

js1 = Arr2(ii + 1) - 1 Else js1 = js End If ks1 = Arr2(ii)

If js1 - ks1 + 1 > 1 Then

Cells(ks1, 4).Resize(js1 - ks1 + 1, 1).Merge For jj = ks1 To js1 If jj <> ks1 Then

Cells(ks, 7) = Cells(ks, 7) + Cells(jj, 7) End If Next

Cells(ks1, 5).Resize(js1 - ks1 + 1, 1).Merge Cells(ks1, 6).Resize(js1 - ks1 + 1, 1).Merge Else

If ii <> 1 Then

Cells(ks, 7) = Cells(ks, 7) + Cells(ks1, 7) End If End If Next

Cells(ks, 7).Resize(js - ks + 1, 1).Merge For ii = ks To js If ii = ks Then r3 = r3 + 1

ReDim Preserve Arr3(1 To r3)

49

常见字典用法集锦及代码详解

Arr3(r3) = ii

ElseIf Cells(ii, 8) <> Cells(ii - 1, 8) Then r3 = r3 + 1

ReDim Preserve Arr3(1 To r3) Arr3(r3) = ii End If Next

For ii = 1 To r3 If ii <> r3 Then

js1 = Arr3(ii + 1) - 1 Else js1 = js End If ks1 = Arr3(ii)

If js1 - ks1 + 1 > 1 Then

Cells(ks1, 8).Resize(js1 - ks1 + 1, 1).Merge For jj = ks1 To js1 If jj <> ks1 Then

Cells(ks1, 9) = Cells(ks1, 9) + Cells(jj, 9) Cells(ks1, 10) = Cells(ks1, 10) + Cells(jj, 10) End If

Cells(ks, 11) = Cells(ks, 11) + Cells(jj, 11) Next

Cells(ks1, 9).Resize(js1 - ks1 + 1, 1).Merge Cells(ks1, 10).Resize(js1 - ks1 + 1, 1).Merge Else

If ii <> 1 Then

Cells(ks, 11) = Cells(ks, 11) + Cells(ks1, 11) End If End If Next

Cells(ks, 11).Resize(js - ks + 1, 1).Merge

50

联系客服:779662525#qq.com(#替换为@)