Hi,
I need to insert a formula for the minimum amount based on 2 calculations. I have the following codes. The codes have 2 criteria. When I run the macro it does not consider the second criteria, which is value in the cell.
Kindly help me:
Sub TRYMAY29()
Dim i, LastRow
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, "A") = "Roger" And Cells(i, "G") = "AV1" And Cells(i, "H") = "HDWE" Then
Cells(i, "w").formula = "=R" & i & "*0.05"
ElseIf Cells(i, "A") = "Roger" And Cells(i, "H") <> "HDWE" And ("=RC[-4]*0.20") >= ("=RC[-2]*0.05") Then
Cells(i, "w").formula = "=U" & i & "*0.05"
ElseIf Cells(i, "A") = "Roger" And Cells(i, "H") <> "HDWE" And ("RC[-4]*0.20") <= ("RC[-2]*0.05") Then
Cells(i, "w").formula = "=R" & i & "*0.20"
Else: Cells(i, "W").formula = "Please update record"
End If
Next
End Sub
I need to insert a formula for the minimum amount based on 2 calculations. I have the following codes. The codes have 2 criteria. When I run the macro it does not consider the second criteria, which is value in the cell.
Kindly help me:
Sub TRYMAY29()
Dim i, LastRow
LastRow = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Cells(i, "A") = "Roger" And Cells(i, "G") = "AV1" And Cells(i, "H") = "HDWE" Then
Cells(i, "w").formula = "=R" & i & "*0.05"
ElseIf Cells(i, "A") = "Roger" And Cells(i, "H") <> "HDWE" And ("=RC[-4]*0.20") >= ("=RC[-2]*0.05") Then
Cells(i, "w").formula = "=U" & i & "*0.05"
ElseIf Cells(i, "A") = "Roger" And Cells(i, "H") <> "HDWE" And ("RC[-4]*0.20") <= ("RC[-2]*0.05") Then
Cells(i, "w").formula = "=R" & i & "*0.20"
Else: Cells(i, "W").formula = "Please update record"
End If
Next
End Sub