把旷工的筛选出去不就行了?
Tables("冲压车间工资表").Sort = "日期,产品名称,生产形式,数量"
For Each ary() As String In DataTables("冲压车间工资表").GetValues("日期|产品名称|生产形式|数量")
Dim drs As List(Of DataRow) = DataTables("冲压车间工资表").Select("日期='" & ary(0) & "' and 产品名称='" & ary(1) & "' and 生产形式='" & ary(2) & "' and 数量 = '" & ary(3) & "' and 备注 not like '%旷工%'")
Dim sum As Double = 0
Dim count As Integer = 0
For Each dr As DataRow In drs
Dim fdr As DataRow = DataTables("价格表").find("产品名称 = '" & dr("产品名称") & "' and 工序 = '" & dr("生产工序") & "'")
If fdr IsNot Nothing
dr("单价") = fdr("单价")
End If
sum += dr("数量") * dr("单价")
count += 1
Next
For Each dr As DataRow In drs
dr("分配金额") = sum / count
Next
Next