老师您好!
我要有一个计算表,属于跨表计算,有15个客户,由于计算内容多,需要将表竖起来计算,所以我将客户名作为列名,将每一个计算内容为一行,有68行,我的计算公式没有问题,自己能写,就是用通用代码怎么将数据写入每一行中,不会循环。我下面计算了两行,第二行hs(2) 是不对的。麻烦给予指教!
Dim hs(68) As Double
Dim je1,je2 As Double
For Each nm As String In DataTables("ddpsb").GetValues("客户")
Dim dr As DataRow = DataTables("ddpsb").find("客户='" & nm & "'")
For Each r As Row In Tables("盈亏计算总表").rows
Dim xm As String = r("项目名称")
hs(1)=DataTables("ddpsb").Compute("Sum(净重)", "[发货日期]<= #" & dt3 & "# and [客户]='" & nm & "'And 发货日期 Is Not null")
je1=DataTables("ddpsb").Compute("Sum(含税金额)", "[发货日期]<= #" & dt3 & "# and [客户]='" & nm & "'And 发货日期 Is Not null")
je1=DataTables("ddpsb").Compute("Sum(不开piao金额)", "[发货日期]<= #" & dt3 & "# and [客户]='" & nm & "'And 发货日期 Is Not null")
hs(2)=je1+je2
If xm="累计总产量"
r(nm)=hs(1)
End If
If xm="累计总产值"
r(nm)=hs(2)
End If
Next
Next
此主题相关图片如下:盈亏表.png