Hi,
I am trying to program a macro that will add up a set of cells in a column, limited to a date, then change the colour of a cell's background to reflect that person's "score" as a percentage.
This is what I have so far:
Sub Check_Button_1()
'Date variables for check start
Dim CurrentDate As Date
Dim iDate As Integer
Dim iCount As Integer
CurrentDate = Format(DateTime.Now, "dd-mm-yyyy")
'MsgBox (CurrentDate)
iDate = 9
DateStart: If CurrentDate <= ActiveSheet.Cells(iDate, 3).Value Then 'This function determines the Last Training Date
'MsgBox (ActiveSheet.Cells(iDate, 3).Value)
iDate = iDate - 1
'MsgBox (ActiveSheet.Cells(iDate, 3).Value)
Else
'MsgBox (ActiveSheet.Cells(iDate, 3).Value)
iDate = iDate + 1
If iDate > 60 Then
GoTo StopDate
Else
GoTo DateStart
End If
StopDate: End If
iCount = iDate - 8
Dim iAttendance As Integer
Dim iMeasure As Integer
iPerson = 4
iMeasure = iCount
iAttendance = 0
While iMeasure >= 1
iAttendance = iAttendance + ActiveSheet.Cells(iCount + 8, 5+ iPerson ).Value
MsgBox (iAttendance)
iMeasure = iMeasure - 1
Wend
End Sub
I have also attached the 2010 file. Attendance Tracker v1 public.xlsm
The goal is to press a button (not added in file) and have the macro run based on the date of the last lesson, and to colour the Present cell under each name yellow if the score is between 60 and 80%, and red if under 60%, and to do the same with the participated cell as well.
EDIT: The above code does partially the first thing (add), but I don't think the code is moving across columns correctly.
Please ask questions if you have them, I know my explanation is somewhat rambling.
Cheers,
Rob
Bookmarks