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