Non Array Summary

seguin85

Active Member
Joined
Mar 17, 2015
Messages
278
Office Version
  1. 365
Platform
  1. Windows
Hi,

I get a data summary from another department and I am trying to pull certain data from it.

It is setup similar to the following:

ABCDEF
1Job#Activity#Start DateEnd DateHours
25-6-71236/20/177/18/17200
35-6-75555/15/178/15/17500
45-6-71238/8/178/1/17300
55-6-71237/16/178/22/17100
65-6-75556/10/179/10/17300

<tbody>
</tbody>


On the summary sheet, I want to be able to type in the job number and activity and it will populate the earliest start date for that combination (ignoring 0 and blanks), the latest end date and the sum of hours. I figured out a way to get it done by an array formula but it is slow down my.

ABCDE
1Job #ActivityStart DateEnd DateHours
2
3
4

<tbody>
</tbody>

Help would be appreciated!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
This might help. There really are only a couple of methods for escaping the need for an array calculation; but arrays are the most efficient method anyway.

Note that the 5-6-7 must be entered as text.

ABCDE
1Job#Activity#Start DateEnd DateHours
25-6-71236/20/20177/18/2017200
35-6-75555/15/20178/15/2017500
45-6-71238/8/20178/1/2017300
55-6-71237/16/20178/22/2017100
65-6-75556/10/20179/10/2017300
7
8
9Look up Job#Look up Activity#Earliest Start DateLatest End DateTotal Hours
105-6-71236/20/20178/22/2017600

<tbody>
</tbody>
Sheet7

Worksheet Formulas
CellFormula
C10=1/AGGREGATE(14,6,1/((A10=A2:A6)*(B10=B2:B6)*C2:C6),1)
D10=AGGREGATE(14,6,(A10=A2:A6)*(B10=B2:B6)*D2:D6,1)
E10=SUMPRODUCT((A10=A2:A6)*(B10=B2:B6)*E2:E6)

<tbody>
</tbody>

<tbody>
</tbody>
 
Last edited:
Upvote 0
This uses array formulas for the earliest start date and latest end date. Just make sure that you limit your ranges and do not use whole column references. You could also format the data as a table to limit the ranges.

I formatted column A on both sheets as Text to ensure that 5-6-7 is not seen as a date.


Excel 2010
ABCDE
1Job #ActivityEarliest Start DateLatest End DateHours
25-6-71236/20/20178/22/2017600
Summary
Cell Formulas
RangeFormula
E2=SUMIFS(Sheet1!E$2:E$6,Sheet1!A$2:A$6,A2,Sheet1!B$2:B$6,B2)
C2{=MIN(IF((Sheet1!A$2:A$6=A2)*(Sheet1!B$2:B$6=B2)*(Sheet1!C$2:C$6>0),Sheet1!C$2:C$6))}
D2{=MAX(IF((Sheet1!A$2:A$6=A2)*(Sheet1!B$2:B$6=B2),Sheet1!D$2:D$6))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Aladin: I don't have minifs and maxifs...

63falcon and DRSteele: Is there a way to determine what method would use the least amount of resources? This is going to be a file I will be using a lot and would like it to remain snappy. I have no problem with arrays but it seemed like my file size was growing quickly as I added a number or arrays.
 
Upvote 0
63falcon and DRSteele: Is there a way to determine what method would use the least amount of resources? This is going to be a file I will be using a lot and would like it to remain snappy. I have no problem with arrays but it seemed like my file size was growing quickly as I added a number or arrays.
Are you willing to try a macro solution? I am not sure how fast it will be for you, but it won't fill your summary sheet with formulas, only the results as constants. If so, the following macro assumes your data is on Sheet1 and the output that you want is on Sheet2, but you can change those by changing the sheet names that I highlighted in red in my code below. The way this works is your summary sheet is assumed to have the headers filled in... what you need to do is list all of the Job numbers and Activity numbers you want summaries for in Columns A and B of your summary sheet, then run the macro which will, in turn, fill in the early start and late end dates and total hours in Columns C:E.
Code:
Sub GetJobActivitySummary()
  Dim R As Long, FM As Long, Sum As Long
  Dim Early As Date, Late As Date, FindWhat As String
  Dim DataWS As Worksheet, SummaryWS As Worksheet
  Dim FindMe As Variant, Data As Variant, Result As Variant
  Set DataWS = Sheets("Sheet1")
  Set SummaryWS = Sheets("Sheet2")
  SummaryWS.Range("C2:E2").Resize(SummaryWS.UsedRange.Rows.Count).ClearContents
  FindMe = SummaryWS.Range("A1").CurrentRegion
  Data = DataWS.Range("A1").CurrentRegion
  ReDim Result(1 To UBound(Data), 1 To 3)
  For FM = 2 To UBound(FindMe)
    FindWhat = FindMe(FM, 1) & "/" & FindMe(FM, 2)
    Early = #9/9/9999#
    Late = 0
    Sum = 0
    For R = 2 To UBound(Data)
      If Data(R, 1) & "/" & Data(R, 2) = FindWhat Then
        If Data(R, 3) < Early Then Early = Data(R, 3)
        If Data(R, 4) > Late Then Late = Data(R, 4)
        Sum = Sum + Data(R, 5)
      End If
    Next
    Result(FM - 1, 1) = Early
    Result(FM - 1, 2) = Late
    Result(FM - 1, 3) = Sum
  Next
  SummaryWS.Range("C2").Resize(UBound(Result), 3) = Result
End Sub

HOW TO INSTALL MACROs
------------------------------------
If you are new to macros, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. To use the macro, go back to the worksheet with your data on it and press ALT+F8, select the macro name (GetJobActivitySummary) from the list that appears and click the Run button. The macro will execute and perform the action(s) you asked for. If you will need to do this again in this same workbook, and if you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

To make things simpler for you (especially if you will need to call this macro often), when you select the macro from the list, before clicking Run, you can click the Options button and assign a keyboard shortcut to it first and then use that keyboard shortcut the next time you want to run the macro. Alternately, you can assign this macro to a Form Control Button so that you can just click it in order to run the macro.
 
Last edited:
Upvote 0
Are you willing to try a macro solution?

Hi Rick,

I would be willing to run macros, I didn't even think of that as a solution. I do have some experience so I imagine I can get your code to work. This way whenever I dump their data into the sheet I just run the macro one time and it will keep my workbook working much more quickly.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,826
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top