Unique Item Count with Multiple Criteria in VBA

pbornemeier

Well-known Member
Joined
May 24, 2005
Messages
3,915
I have a worksheet listing about 35000 jobs that were done over 4 years. Layout is start date in column A, finish data in column B and the supervisor in column C. I defined dynamic named ranges to cover each column. Start = KO_AS, Finish = KO_AF, Supervisor = KO_SUPERVISOR.
KO_SUPERVISOR_START is the named range of the first cell in the Supervisor column.

I want to create another worksheet with a range of dates in column A that covers the earliest start to latest finish dates from the previous; Column C to contain the count of jobs that were active on that day; column D to contain the number jobs that did not have a listed supervisor assigned and Column E to contain the number of non-blank supervisors that had jobs active that day.

The formulas I worked out for these columns are:
Code:
C2 =SUMPRODUCT(--(KO_AS<='Sheet1'!A2),--(KO_AF>='Sheet1'!A2))
D2 =SUMPRODUCT(--(KO_AS<='Sheet1'!A2),--(KO_AF>='Sheet1'!A2),--(KO_SUPERVISOR=""))

I found this post http://www.mrexcel.com/forum/showthread.php?t=373877 that helped me create a formula (which I still do not fully understand, but that appears to work) to calculate column E (formula is confirmed with CSE):
Code:
E2 =SUM(IF(FREQUENCY(IF(KO_AS<=A1,IF(KO_AF>=A1,IF(KO_SUPERVISOR<>"",MATCH("~"&KO_SUPERVISOR,KO_SUPERVISOR&"",0)))),ROW(KO_SUPERVISOR)-ROW(KO_SUPERVISOR_START)+1),1))

All formulas are copied down the date range of dates.

The CSE formula works, but it is very slow, when I use it (on ~1500 dates and 35000 jobs). Is there a faster solution for the column E data using VBA?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
E2 formula is actually:
Code:
E2 =SUM(IF(FREQUENCY(IF(KO_AS<=A2,IF(KO_AF>=A2,IF(KO_SUPERVISOR<>"",MATCH("~"&KO_SUPERVISOR,KO_SUPERVISOR&"",0)))),ROW(KO_SUPERVISOR)-ROW(KO_SUPERVISOR_START)+1),1))
 
Upvote 0

Forum statistics

Threads
1,222,404
Messages
6,165,853
Members
451,987
Latest member
Johnzdz

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