有人可以解释一下如何让这个宏在整个列上运行而不是单行单元格吗?即检查每个单独单元格的值,并在其所在行的相应单元格中执行所需的计算和输出。
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