This should do the job:
Sub add_subtotal()
'code by xlbiznes - 10th jan 2014
x = 2 ' since there is a column header in row 1, we start from row 2.
tot_hrs = 0 ' to calculate the hours worked
'start loop
Do
If IsNumeric(Range("i" & x)) = True Then 'check if hrs worked is numeric and add to tot_hrs
tot_hrs = tot_hrs + Range("i" & x)
End If
If UCase(Range("d" & x)) = "FRIDAY" And UCase(Range("d" & x + 1)) <> "FRIDAY" Then 'check if end of week has occurred, skip if there are two successive friday
Rows(x + 1).Insert 'insert row
x = x + 1
Range("J" & x) = tot_hrs 'put total hrs worked for the week
tot_hrs = 0 'initalize tot_hrs to 0
End If
x = x + 1 'increment row
If Range("a" & x) = "" Then ' check if you have hit the end of data, if so exit loop
Exit Do
End If
Loop
MsgBox "Process Completed", vbInformation, "Xlbiznes"
End Sub
Bookmarks