|
楼主 |
发表于 2017-3-24 14:16
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 讲古派 于 2017-3-24 14:21 编辑
知识有限. 还是看不太懂.绕晕了.
我用了最死的方法,
可以求出3级.但3级都已经快绕晕了. 有办法简化吗.
Private Sub CommandButton2_Click()
arr = Range("a1").CurrentRegion
ReDim brr(5 To UBound(arr)) As Currency
For k = 5 To UBound(arr)
brr(k) = arr(k, 8) 第8列是单价
For j = 13 To UBound(arr, 2) 第13列开始是矩形BOOM表
If arr(k, 1) = arr(1, j) Then
For m = 5 To UBound(arr)
If arr(m, j) <> "" Then
brr(k) = brr(k) + arr(m, j) * arr(m, 8)
'--------------------------------------
For n = 13 To UBound(arr, 2)
If arr(m, 1) = arr(1, n) Then
For x = 5 To UBound(arr)
If arr(x, n) <> "" Then
brr(k) = brr(k) + arr(x, n) * arr(x, 8)
'-----------------------------------------------
For y = 13 To UBound(arr, 2)
If arr(x, 1) = arr(1, y) Then
For Z = 5 To UBound(arr)
If arr(Z, y) <> "" Then
brr(k) = brr(k) + arr(Z, y) * arr(Z, 8)
End If
Next
End If
Next
'---------------------------------------------------
End If
Next
End If
Next
'----------------------------------------
End If
Next
End If
Next
Next
Range("k5:k" & UBound(arr)).Value = Application.WorksheetFunction.Transpose(brr)
Unload Me
End Sub
|
|