以下是引用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编辑过]