Forum Discussion
Adding Hours on a Schedule Spreadsheet
Lisa-
I have created a User Defined Function (UDF) that will help you. In order to use it you will need to follow these steps:
1. Use Key Combination Alt + F11 to access the Visual Basic Editor
2. Go To Insert > Module
3. Paste this code in the window that appears:
Function GetEEHours(SearchFor As Range, SearchIn As Range) As Single
Dim fnd As String
Dim cll As Range
Dim Total As Single
If SearchFor.Count > 1 Then Exit Function
fnd = SearchFor.Value
For Each cll In SearchIn
If cll.Value = fnd Then
Total = Total + cll.Offset(, -1).Value
End If
Next cll
GetEEHours = Total
End Function
4. Save file as Macro Enabled Workbook
5. Use this Syntax with the new UDF =GetEEHours(SearchFor, SearchIn)
i.e. In Cell E15 the formula looks like this: =GetEEHours(A15,$A$1:$AB$13)
The UDF basically searches the range you provide for the word "Eric" (Cell A15) then when it finds the word Eric it looks to the Left of it to get the hours they are working....then it goes to the next one...and so forth.
I'm attaching a workbook with the syntax. However, you will need to insert the code as mentioned above. This forum does not allow me to attach a macro enabled files (Files with Code).