|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
写了个蹩脚的程序+函数 混合体,起码能实现你的要求
Sub chongpai()
Dim a, b, c, d, i, j, k, m, n
Range("E2:L9").Clear
a = 0
For i = 2 To 7
If Cells(i, 2) = Cells(2, 4) Then
Cells(a + 3, 7) = Cells(i, 1)
Cells(a + 3, 8) = Cells(i, 2)
a = a + 1
b = Cells(i, 2) + b
End If
Next
For i = 2 To 7
If Cells(i, 2) = Cells(4, 4) Then
Cells(a + 3, 7) = Cells(i, 1)
Cells(a + 3, 8) = Cells(i, 2)
a = a + 1
b = Cells(i, 2) + b
End If
Next
Cells(a + 3 - 1, 11) = b
c = a + 3
For i = 2 To 7
If (Cells(i, 2) - Cells(2, 4)) * (Cells(i, 2) - Cells(4, 4)) <> 0 Then
Cells(a + 4, 7) = Cells(i, 1)
Cells(a + 4, 9) = Cells(i, 2)
a = a + 1
End If
Next
For i = 2 To c
Cells(i, 10) = b
Next
End Sub
|
|