FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,362
- Office Version
- 365
- 2016
- Platform
- Windows
I'm currently using VBA code to produce unique values in column D starting in D2 (Sheet2). This works great, but taking the next step, I'm using a Sumifs formula to create an org chart type summation for that office in Column E at E2..
Here is a small snippet of what I'm trying to accomplish. In the results table, as you can see I'm using a Sumifs to calculate the totals. Hoping this can be done with VBA versus the Sumifs!
Source
Result
Here is a small snippet of what I'm trying to accomplish. In the results table, as you can see I'm using a Sumifs to calculate the totals. Hoping this can be done with VBA versus the Sumifs!
Source
Testing Org Chart.xlsm | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
B | E | AA | AO | |||||||||||||||||||||||||||||||||||||||
1 | Hdr1 | Hdr2 | Hdr3 | QTR | ||||||||||||||||||||||||||||||||||||||
2 | OFFICE | LL | O | 1 | ||||||||||||||||||||||||||||||||||||||
3 | OFFICE | XCF | A | 1 | ||||||||||||||||||||||||||||||||||||||
4 | OFFICE | XCF | A | 1 | ||||||||||||||||||||||||||||||||||||||
5 | OFFICE | DPX | O | 1 | ||||||||||||||||||||||||||||||||||||||
6 | OFFICE | DPX | A | 1 | ||||||||||||||||||||||||||||||||||||||
7 | OFFICE | DPX | C | 1 | ||||||||||||||||||||||||||||||||||||||
8 | OFFICE | DPX | A | 1 | ||||||||||||||||||||||||||||||||||||||
9 | OFFICE | DPX | A | 1 | ||||||||||||||||||||||||||||||||||||||
10 | OFFICE | DPX | C | 1 | ||||||||||||||||||||||||||||||||||||||
11 | OFFICE | DPX | A | 1 | ||||||||||||||||||||||||||||||||||||||
12 | OFFICE | DPX | A | 1 | ||||||||||||||||||||||||||||||||||||||
Chart |
Result
Cell Formulas | ||
---|---|---|
Range | Formula | |
E2:E4 | E2 | =SUMIFS(Chart!AO:AO,Chart!B:B,Sheet2!$C$2,Chart!AA:AA,"O",Chart!E:E,Sheet2!D2)&"/"& SUMIFS(Chart!AO:AO,Chart!B:B,Sheet2!$C$2,Chart!AA:AA,"A",Chart!E:E,Sheet2!D2)&"/"& SUMIFS(Chart!AO:AO,Chart!B:B,Sheet2!$C$2,Chart!AA:AA,"C",Chart!E:E,Sheet2!D2)&"/"& SUMIFS(Chart!AO:AO,Chart!B:B,Sheet2!$C$2,Chart!E:E,Sheet2!D2) |
VBA Code:
Sub FilterLevel1()
Dim Dn As Range
Dim rng As Range: Set rng = Sheet1.Range("E2", Sheet1.Range("E" & Sheet1.Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In rng
If Not .Exists(Dn.Value) _
And Dn.Offset(, -3).Value = Sheets("Sheet2").Range("C2").Value Then
.Add Dn.Value, ""
End If
Next
Sheet2.Cells(2, 5).Resize(.Count).Value = Application.Transpose(.keys)
End With
End Sub