Please help! I'm fairly new to working with macros and I am having trouble figuring out how to get my macro to loop within an If Then Else so that it will run a column and check if 'Hours' are either:
Is there a better way to write my macro to get the desired results that I need....
This is what I have:
'Check if enough Avail Sick Time Hours and Round Hours Worked
Range("EXCEPTIONS[Hours]").Select
For Each cell In Range("EXCEPTIONS[Hours]")
If Value < "EXCEPTIONS[AvailHours]" Then
Range("EXCEPTIONS[Reason]").Value = "Not enough hours earned"
ElseIf Value < 4 Then
Range("EXCEPTIONS[Reason]").Value = "Pay for 4 hours"
ElseIf Value >= 4 Then
Range("EXCEPTIONS[Reason]").Value = "Pay for 8 hours"
End If
Next cell
Output Reason I Get:
This is what I am trying to get it to do for the Reason:
- Greater than 'AvailHours' Then the output for 'Reason' would be "Not enough hours earned"
- 'Hours' < 4 Then the output for 'Reason' would be "Pay for 4 hours"
- 'Hours' >= 4 Then the output for 'Reason' would be "Pay for 8 hours"
- If the output for 'Reason' is "Not enough hours earned" then I need that row to move to the bottom
Is there a better way to write my macro to get the desired results that I need....
This is what I have:
'Check if enough Avail Sick Time Hours and Round Hours Worked
Range("EXCEPTIONS[Hours]").Select
For Each cell In Range("EXCEPTIONS[Hours]")
If Value < "EXCEPTIONS[AvailHours]" Then
Range("EXCEPTIONS[Reason]").Value = "Not enough hours earned"
ElseIf Value < 4 Then
Range("EXCEPTIONS[Reason]").Value = "Pay for 4 hours"
ElseIf Value >= 4 Then
Range("EXCEPTIONS[Reason]").Value = "Pay for 8 hours"
End If
Next cell
Output Reason I Get:
This is what I am trying to get it to do for the Reason: