Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We did not have any problem with Bob's function.
for your benefit, we converted this function as subroutine as follow. Tested OK Sub t() 'Function GetTotals(Source As String, Resource As Range, MatchDate As Range) Dim Source As String 'added Dim Resource As Range 'added Dim MatchDate As Range 'added Dim i As Long Dim iLastrow As Long Dim iStart As Long Dim iEnd As Long Dim tmp Source = "sheet1" 'added Set Resource = Range("A2") 'added Set MatchDate = Range("B1") 'added iLastrow = Worksheets(Source).Cells(Worksheets(Source).Rows.C ount, "A").End(xlUp).Row On Error Resume Next iStart = Application.Match(Resource.Value, Worksheets(Source).Range("B:B"), 0) If iStart 0 Then iEnd = Application.Match("Agent:", Worksheets(Source).Range("A" & iStart + 1 & ":A" & Rows.Count), 0) + iStart If iEnd = 0 Then iEnd = iLastrow End If On Error GoTo 0 For i = iStart To iEnd If Worksheets(Source).Cells(i, "A").Value = MatchDate.Value Then tmp = CDate(Worksheets(Source).Cells(i, "G").Value) End If Next i End If ' GetTotals = tmp Range("b2") = tmp 'added End Sub You have to adjust the code to suit your need. Currently it works for range("B2") only "Dorn" wrote in message ... Unfortunately I haven't used user defined functions before (haha I'm pretty sure this should be on the newbie discussion board) I tried to save it as a macro and it gave me a "syntax error" and highlights the first row. As for the columns k through n they reflect the employees status in our phone system, logged in is self explanatory, acd means that they will be randomly distributed phone calls of callers who call our sales teams non acd means they will only receive calls intended only for them and dnd means they won't receive calls. I was hoping to be able to pull the time for those categories in the same format of the times pulled from the "total times" for each of those dates. You guys are really helping me out here, thanks a bunch! "PY & Associates" wrote: Bob Phillips has given a working solution. I trust you are happy with it. For our curiosity, what do you expect in sheet2 columns K to N please? "Dorn" wrote in message ... The dates in row one could be manually entered by me, but I'm assuming they should be formatted as text to match the source data. As for an example of what I expect in row 2, I'm having trouble with my ftp client so I'll try to explain: Under each date I need the total hours worked for that day, which is located in the same row as the date I just need it to copy the contents of the cell referenced by the date. Example would be cell G25 and for the columns on the right that information can be found next to the names of the employees example would be row 22 under the appropriate headings. Thanks for the help! "PY & Associates" wrote: Where are the DATES in row 1 come from? Try fill up row 2 to show the result you expect please. "Dorn" wrote in message ... FYI: the data I need for each employee under each date is the "total time" which is located on the same row as the date and in column "G" of my sample. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to summarize data | Excel Worksheet Functions | |||
Macro - Too hard for me!! | Excel Discussion (Misc queries) | |||
Macro -Far too Hard for me !! | Excel Worksheet Functions | |||
Macro - Too hard for me!! | Excel Discussion (Misc queries) | |||
Macro or VB Code to Summarize Info.from 4 workbooks | Excel Programming |