ScatmanKyle
Board Regular
- Joined
- Oct 26, 2015
- Messages
- 65
- Office Version
- 365
- Platform
- Windows
I have a database that I pull from a dashboard where I need to insert details into a separate file/format to check the accuracy of data.
Each unique "Business" has to have its own tab in the file. Within each business, the campaigns need to have a table set up that contain the platforms, then the metric data is pulled in.
So far I've managed to use the dictionary function to create the individual tabs (Test dict being the tab with the data):
At the moment, I'm stuck on how to:
1) Create a separate dictionary for the campaigns and for the platforms
2) Use a sumifs statement from dictionary variables (since the data I'm using has data for all of the businesses/campaigns/platforms).
A | B | C | D | E | F |
Business | Campaign | Platform | Metric 1 | Metric 2 | Metric 3 |
Each unique "Business" has to have its own tab in the file. Within each business, the campaigns need to have a table set up that contain the platforms, then the metric data is pulled in.
So far I've managed to use the dictionary function to create the individual tabs (Test dict being the tab with the data):
VBA Code:
Sub TabSetup()
'Creating the dictionary for Business
Dim dictLOB As Object
Dim rngLOB As Range
Dim lngLastRow As Long
Dim varTab As Variant
ThisWorkbook.Sheets("Test dict").Activate
lngLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set dictLOB = CreateObject("Scripting.Dictionary")
For Each rngLOB In Range("A2:A" & lngLastRow)
If Not dictLOB.exists(rngLOB.Value) Then dictLOB.Add rngLOB.Value, Nothing
Next
'MsgBox (dictLOB.Count & " distinct LOBs")
'Setting up tabs
For Each Key In dictLOB
Sheets.Add(After:=Sheets(Sheets.Count)).Name = Key
Next
End Sub
At the moment, I'm stuck on how to:
1) Create a separate dictionary for the campaigns and for the platforms
2) Use a sumifs statement from dictionary variables (since the data I'm using has data for all of the businesses/campaigns/platforms).