Reputation: 1
I have a data sheet, which contains names of people and hours per day that they worked. I need to sum the numbers worked per day and week for each person. The sheet looks like this
A B
Peter 8.000
Bob 4.000
Jane 3.000
Jane 4.000
Each person has several entries and my boss wants me to show them on weekly and monthly basis, so he is able to track if someone has done overtime more recently than others.
Upvotes: 0
Views: 435
Reputation: 149295
I agree with Jmax and KingCronus here. You actually do not need a macro. You can achieve it with a formula.
NON VBA
I am assuming that the values are in Col A and Col B.
=SUMPRODUCT((A:A="Jane")*(B:B))
VBA
If you still want VBA then you can use this
Sub Sample()
Dim sName As String
sName = "Jane"
Debug.Print Application.Evaluate("=SUMPRODUCT((A:A=" & _
Chr(34) & sName & Chr(34) & ")*(B:B))")
End Sub
Upvotes: 1