0
有人可以解释如何让这个宏在整列上运行,而不是单行单元格吗?即检查每个单独单元的值并且在其行上的相应单元中执行所需的计算和输出。将Excel VBA单行宏应用于单元格范围
Sub Calculate_Costs()
If Cells(2, 7) = "One Man" And Cells(2, 6) >= Cells(2, 5) Then
Cells(2, 8) = 6.5 + ((Cells(2, 6) - 20) * 0.23)
ElseIf Cells(2, 7) = "One Man" And Cells(2, 6) < Cells(2, 5) Then
Cells(2, 8) = 6.5 + ((Cells(2, 5) - 20) * 0.23)
ElseIf Cells(2, 7) = "Two Man" And Cells(2, 6) >= Cells(2, 5) Then
Cells(2, 8) = 38 + ((Cells(2, 6) - 50) * 0.38)
ElseIf Cells(2, 7) = "Two Man" And Cells(2, 6) < Cells(2, 5) Then
Cells(2, 8) = 38 + ((Cells(2, 5) - 50) * 0.38)
Else
Cells(2, 14) = "This is not working"
End If
End Sub
它确实有效。非常感谢 – Pradeep 2013-02-15 12:26:27