Dim r As Row Static s As String Dim s1 As String Dim n As Double For i As Integer = 0 To Tables("材料帐页").Rows.Count(True) - 1
r = Tables("材料帐页").Rows(i,True) If r.IsGroup Then s1 = r("材料") If s = "" OrElse s1 <> s Then n = r("入仓_数量") - R("出仓_数量") r("库存_数量") = n Else n + = r("入仓_数量") - R("出仓_数量") r("库存_数量") = n End If s = s1 End If Next