I have an Attendance spreadsheet where I need to SUM a row and have the totals in the last columns. Each row represents an employee and each column represents a day in the month. The reason I am using VBA is because some date columns will contain text, such as TA for Tardy and need to add 0.5 to the total if TA is present in one or more of the cells in the range.
I can only get the first row to populate, but not the rows below it. I am guessing it is because I am not setting my ranges correctly. Here is the code that I have so far:
Dim wsJAN As Worksheet 'Used to reference the sheet by its TAB name in the WB
Dim LastRow As Long 'Last used row on sheet
Dim tDays As Range 'Total # of days the employee has actually worked
Dim cDays As Range 'Current # of days the employee should have worked
Dim rowEmployee As Range 'Used to define the columns to be used to when adding attendance for each employee row
Dim rCell As Range
LastRow = Cells.Find(What:="*", After:=[A3], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Application.ScreenUpdating = False
Set wsJAN = ThisWorkbook.Sheets("JAN")
Set tDays = wsJAN.Range("AG3")
Set cDays = wsJAN.Range("AH3")
Set rowEmployee = wsJAN.Range("B3:AF3")
tDays = "=SUM(B3:AF3)"
cDays = "=SUM(B3:AF3)"
For Each rCell In rowEmployee
If rCell.Value = "TA" Then
tDays = tDays + 0.5 ' Add only a half day to the # of days the employee has worked in Column AG if tardy.
cDays = cDays + 1 ' Add a whole day to current days worked in Column AH if employee is tardy.
End If
Next
Application.ScreenUpdating = True
I have even tried using For i = 1 To LastRow Step 1 around the For Each loop and Do.....Loop Until LastRow with out any success. My rows will always start at row 3 so I need something along the lines of :
AG3 =SUM(B3:AF3)
AG4 =SUM(B4:AF4)
Down to the last row

BtoAF? In other words, is the total always in ColAG?