Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Lucina Ferrrari   on Oct 25 In MS Office Category.

  
Question Answered By: Kellie Bishop   on Oct 25

Is there any problem with putting the totals in the column with the list?
If you could use a function like: =COUNTA(B2:B50), =COUNTA(C2:C50), etc
in each column, (and put it, say, row 51) then you can use hlookup to get the
number:
=HLOOKUP(A1,Attendance!B1:U51,51,FALSE)

If you'd prefer a VBA solution:

In a VBA Module, I put:
Global DateCnt, DateCol, DateRange, Data
Public Function Check_Attendance(ChkDate)
If (IsDate(ChkDate)) Then
DateCnt =
Application.WorksheetFunction.CountA(Sheets("Sheet1").Range("A1:IV1"))
Set DateRange = Worksheets("Sheet1").Range("A1:" & Cells(1,
DateCnt).Address)
For Each Data In DateRange.Rows(1).Cells
If (ChkDate = Data.Value) Then
Check_Attendance =
Application.WorksheetFunction.CountA(Sheets("Sheet1").Range(Cells(2,
Data.Column).Address & ":" & Cells(1000, Data.Column).Address))
Exit For
End If
Next Data
End If
End Function

then, in Sheet2, cell B2, I used the function:
=Check_Attendance(A1)

I'm pretty sure there's a cleaner way to define the range for the CountA
worksheetfunction,
but I kept getting errors. this works, so I let it run...

Share: