Hello again, the following looks the key to determine the number of unique events. You'll want to change DataSheet to your sheet name and Sheets(1) to your target sheet in all instances:
<font face=Courier New><SPAN style="color:darkblue">Sub</SPAN> PtReplace()
<SPAN style="color:darkblue">Dim</SPAN> cn <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>, rs <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Object</SPAN>
<SPAN style="color:darkblue">Dim</SPAN> clcMde <SPAN style="color:darkblue">As</SPAN> <SPAN style="color:darkblue">Long</SPAN>
clcMde = Application.Calculation
Application.ScreenUpdating = <SPAN style="color:darkblue">False</SPAN>
Application.Calculation = xlCalculationManual
Sheets(1).[a2:iv65536].ClearContents
<SPAN style="color:darkblue">Set</SPAN> cn = CreateObject("ADODB.Connection")
cn.<SPAN style="color:darkblue">Open</SPAN> "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
ThisWorkbook.FullName & ";Extended Properties=Excel 8.0;" <SPAN style="color:green">'Create DB connection</SPAN>
<SPAN style="color:darkblue">Set</SPAN> rs = CreateObject("ADODB.Recordset")
<SPAN style="color:darkblue">With</SPAN> rs
<SPAN style="color:darkblue">Set</SPAN> .ActiveConnection = cn
.Source = "SELECT t1.Blah, COUNT(*) <SPAN style="color:darkblue">As</SPAN> Cnt " & _
"From (SELECT DISTINCT [Incident Key], [Incident <SPAN style="color:darkblue">Type</SPAN> Class] <SPAN style="color:darkblue">As</SPAN> Blah " & _
"From [DataSheet$a1:iv65536]) AS T1 Group By T1.Blah"
.<SPAN style="color:darkblue">Open</SPAN> , , 3, 3
Sheets(1).[a2].CopyFromRecordset rs
.<SPAN style="color:darkblue">Close</SPAN>
.Source = "Select sum([Time]), sum([Number Of Personnel]) " & _
"From [DataSheet$a1:iv65536] Group By [Incident <SPAN style="color:darkblue">Type</SPAN> Class]"
.<SPAN style="color:darkblue">Open</SPAN> , , 3, 3
Sheets(1).[c2].CopyFromRecordset rs
.<SPAN style="color:darkblue">Close</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">With</SPAN>
cn.<SPAN style="color:darkblue">Close</SPAN>
<SPAN style="color:darkblue">Set</SPAN> rs = Nothing: <SPAN style="color:darkblue">Set</SPAN> cn = <SPAN style="color:darkblue">Nothing</SPAN>
Application.Calculation = clcMde
Application.ScreenUpdating = <SPAN style="color:darkblue">True</SPAN>
<SPAN style="color:darkblue">End</SPAN> <SPAN style="color:darkblue">Sub</SPAN></FONT>
Put headers in row 1. It's dynamic. Just rerun it when you want a freshy.