D
Dan E
I'm on a 2-hour deadline to get this sub working, and, since I'm new to VBA,
I don't know enough to know which particular very stupid thing I'm doing.
Having said that, if some kind soul can point me in the right direction to
fix this, blessings will be upon your head. This stops in 'week2' with
runtime error 424 - Object required - it's working on a scheduling worksheet
and is looking for overtime hours in particular cases - hence the values 1,
2 or 3 in column W in rows where column AT is X. I know I don't yet know if
number values require "" even.... mutter mutter
:-
Sub CC_OT()
Dim oRow As Range
Dim cell As Range
On Error GoTo ws_next3
For Each oRow In ActiveSheet.UsedRange.Rows
If Cells(oRow.Row, "AT").Value = "X" Then
If Cells(oRow.Row, "W").Value = "1" Then
week1
ElseIf Cells(oRow.Row, "W").Value = "2" Then
week2
ElseIf Cells(oRow.Row, "W").Value = "3" Then
bothweeks
End If
End If
ws_next3:
Next oRow
End Sub
Sub week1()
If Cells(oRow.Row, "AW").Value > 40 Then
Cells(oRow.Row, "BA").Value = Cells(oRow.Row, "AW").Value - 40
End If
End Sub
Sub week2()
If Cells(oRow.Row, "AX").Value > 40 Then
Cells(oRow.Row, "BA").Value = Cells(oRow.Row, "AX").Value - 40
End If
End Sub
Sub bothweeks()
Cells(oRow.Row, "BA").Value = 0
If Cells(oRow.Row, "AW").Value > 40 Then
Cells(oRow.Row, "BA").Value = Cells(oRow.Row, "AW").Value - 40
End If
If Cells(oRow.Row, "AX").Value > 40 Then
Cells(oRow.Row, "BA").Value = (Cells(oRow.Row, "BA").Value + _
(Cells(oRow.Row, "AW").Value - 40))
End If
End Sub
TIA
Dan
I don't know enough to know which particular very stupid thing I'm doing.
Having said that, if some kind soul can point me in the right direction to
fix this, blessings will be upon your head. This stops in 'week2' with
runtime error 424 - Object required - it's working on a scheduling worksheet
and is looking for overtime hours in particular cases - hence the values 1,
2 or 3 in column W in rows where column AT is X. I know I don't yet know if
number values require "" even.... mutter mutter

Sub CC_OT()
Dim oRow As Range
Dim cell As Range
On Error GoTo ws_next3
For Each oRow In ActiveSheet.UsedRange.Rows
If Cells(oRow.Row, "AT").Value = "X" Then
If Cells(oRow.Row, "W").Value = "1" Then
week1
ElseIf Cells(oRow.Row, "W").Value = "2" Then
week2
ElseIf Cells(oRow.Row, "W").Value = "3" Then
bothweeks
End If
End If
ws_next3:
Next oRow
End Sub
Sub week1()
If Cells(oRow.Row, "AW").Value > 40 Then
Cells(oRow.Row, "BA").Value = Cells(oRow.Row, "AW").Value - 40
End If
End Sub
Sub week2()
If Cells(oRow.Row, "AX").Value > 40 Then
Cells(oRow.Row, "BA").Value = Cells(oRow.Row, "AX").Value - 40
End If
End Sub
Sub bothweeks()
Cells(oRow.Row, "BA").Value = 0
If Cells(oRow.Row, "AW").Value > 40 Then
Cells(oRow.Row, "BA").Value = Cells(oRow.Row, "AW").Value - 40
End If
If Cells(oRow.Row, "AX").Value > 40 Then
Cells(oRow.Row, "BA").Value = (Cells(oRow.Row, "BA").Value + _
(Cells(oRow.Row, "AW").Value - 40))
End If
End Sub
TIA
Dan