I have been trying to resolve this issue but no success. Everytime I tried to run the code it gives Bach "Do without Loop" error. I checked the codes and so far no luck in finding the error. I have Do and End If on every statements so I am not sure anymore what is the problem. Please help. Thank you.
Sub Calculation
Dim Row As Integer
Dim endLine As Long, hundert As Double, startDate As Variant, endDate As Variant, currDate As Date
Row = 5
Do While Cells(Row, 5) <> ""
endLine = Cells(Rows.Count, 1).End(x1Up).Row
wTime = 0
tempWNum = -1
Range("L" & Row & ":V" & endLine).Clear
Call GroupTimes(Rows, endLine)
Do Until endLine < Row
startDate = Cells(Row, 8)
endDate = Cells(Row, 9)
dTime = (endDate - startDate) * 24
currDate = Cells(Row, 1).Value2
entryState = Cells(Row, 6).Value2
If entryState = "Sick" Then
Cells(Row, 17) = dTime
GoTo ContinueDo
End If
If entryState = "Vacation" Then
Cells(Row, 18) = dTime
GoTo ContinueDo
End If
If entryState = "ZA" Then
Cells(Row, 19) = dTime
GoTo ContinueDo
End If
wTime = wTime + dTime
If Not IsEmpty(Cells(Row, 1).Value2) Then
wnum = IsoWeekNumber(currDate)
End If
If tempWNum < 0 Then
tempWNum = wnum
End If
If wnum > tempWNum Then
wTime = wTime - dTime
Cells(Row - 1, 21) = wTime
wTime = dTime
tempWNum = wnum
End If
If IsEmpty(startDate) Or IsEmpty(endDate) Then
GoTo ContinueDo
End If
If Not Weekday(Cells(Row, 1)) = 1 Then
hundert = GetTimeHundertPerc(startDate, endDate)
End If
If hundert > 0 Then
conv = hundert * 24
Cells(Row, 16) = conv
dTime = dTime - conv
hundert = 0
End If
If Weekday(Cells(Row, 1)) = 1 Then
Cells(Row, 16) = dTime
Else
If dTime > 0 Then
If dTime <= 8 Then
Cells(Row, 14) = dTime
Else
If (dTime - 8) > 0 Then
Cells(Row, 14) = 8
Cells(Row, 15) = dTime - 8
End If
End If
End If
End If
startDate = Cells(Row, 8)
ContinueDo:
Row = Row + 1
Loop
'write last week time
Cells(Row - 1, 21) = wTime
End Sub
Bookmarks