注册 登录
编程论坛 Excel/VBA论坛

【提问】这个工资怎么用函数计算???

matt0415 发布于 2018-11-30 22:36, 2099 次点击
只有本站会员才能查看附件,请 登录


只有本站会员才能查看附件,请 登录
3 回复
#2
xyxcc1772018-12-01 18:15
只有本站会员才能查看附件,请 登录
做好了
#3
wengjl2018-12-14 11:00
会不会出现第4种情况呢?  就是 助手为无,后勤有人参与。
#4
xs5912222018-12-15 12:46
以下是引用xyxcc177在2018-12-1 18:15:50的发言:

做好了

Function SetMoneyToWorker(ByVal rng As Range, ByVal Target As Range) As Double
Dim dValue As Double
Dim sName As String
Dim i, s As Integer
sName = rng.Value
Dim strNoThing As String
Dim rowCount As Integer
rowCount = Target.Rows.Count
dValue = 0
strNoThing = "无"
   For i = 1 To rowCount
         
          If Target.Cells(i, 1) = sName Then
             If Target.Cells(i, 2) = strNoThing And Target.Cells(i, 3) = strNoThing Then
                dValue = dValue + Target.Cells(i, 4)
             ElseIf Target.Cells(i, 2) <> strNoThing And Target.Cells(i, 3) = strNoThing Then
                dValue = dValue + Target.Cells(i, 4) * 0.55
             ElseIf Target.Cells(i, 2) <> strNoThing And Target.Cells(i, 3) <> strNoThing Then
                dValue = dValue + Target.Cells(i, 4) * 0.5
             End If
          End If
          If Target.Cells(i, 2) = sName Then
             If Target.Cells(i, 3) = strNoThing Then
                dValue = dValue + Target.Cells(i, 4) * 0.45
             Else
                 dValue = dValue + Target.Cells(i, 4) * 0.3
             End If
          End If
          If Target.Cells(i, 3) = sName Then
              dValue = dValue + Target.Cells(i, 4) * 0.2
          End If
     
   Next
  SetMoneyToWorker = Format(dValue, "0.00")
End Function
@xyxcc177 能用中文注释每一个语句的中文意思吗?

[此贴子已经被作者于2018-12-20 18:59编辑过]

1