stillwillyboy
Technical User
In the following, the first If with the 180, 181 or 182 works, but as it loops thru, it blows past the others. It ignores the next two If statements. I have verified my data and there are cells with 186, 187, 189 and above.
Sub CalculatePay()
Application.ScreenUpdating = False
Range("A2").Select
Do
With ActiveCell
If ActiveCell = 180 Or 181 Or 182 Then
ActiveCell.Offset(0, 5) = ActiveCell.Offset(0, 1) * _
ActiveCell.Offset(0, 3)
ElseIf ActiveCell > 182 And ActiveCell < 189 Then
ActiveCell.Offset(0, 5) = ActiveCell.Offset(0, 1) * _
ActiveCell.Offset(0, 4)
ElseIf ActiveCell > 189 Then
ActiveCell.Offset(0, 5) = ActiveCell.Offset(0, 2) * _
ActiveCell.Offset(0, 3)
End If
End With
With ActiveCell
.Offset(1, 0).Select
End With
Loop Until ActiveCell = ""
Range("A1").Select
End Sub
TIA
Bill
Sub CalculatePay()
Application.ScreenUpdating = False
Range("A2").Select
Do
With ActiveCell
If ActiveCell = 180 Or 181 Or 182 Then
ActiveCell.Offset(0, 5) = ActiveCell.Offset(0, 1) * _
ActiveCell.Offset(0, 3)
ElseIf ActiveCell > 182 And ActiveCell < 189 Then
ActiveCell.Offset(0, 5) = ActiveCell.Offset(0, 1) * _
ActiveCell.Offset(0, 4)
ElseIf ActiveCell > 189 Then
ActiveCell.Offset(0, 5) = ActiveCell.Offset(0, 2) * _
ActiveCell.Offset(0, 3)
End If
End With
With ActiveCell
.Offset(1, 0).Select
End With
Loop Until ActiveCell = ""
Range("A1").Select
End Sub
TIA
Bill