dversloot1
Board Regular
- Joined
- Apr 3, 2013
- Messages
- 113
Hello,
I've managed to filter OLAP Pivots before if the CurrentFieldName was one option. Now, I have a range of dates that cannot be selected using the between function because the OLAP Cube isn't set up that way. I've set up a date table in my workbook that has all the possible dates between a selected range from a combox in my userform.
The trick is that not all dates will be in the Cube. So I'm hoping to skip the ones that aren't in the pivot until the macro loops through all of my array.
Here is a recorded macro of what I would like to do:
Sub Macro4()
ActiveSheet.PivotTables("PivotTable3").PivotFields( _
"[PO Details].[PO Receipt].[PO Receipt]").VisibleItemsList = Array( _
"[PO Details].[PO Receipt].&[2015-01-06T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-07T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-08T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-09T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-10T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-12T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-13T00:00:00]")
End Sub
My attempt is the following but it doesn't handle errors (Date not in cube)
Sub Macro3()
Dim a, b, c, d, e, f, g As String
a = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 2, False), "yyyy-mm-dd") & "T00:00:00]"
b = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 3, False), "yyyy-mm-dd") & "T00:00:00]"
c = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 4, False), "yyyy-mm-dd") & "T00:00:00]"
d = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 5, False), "yyyy-mm-dd") & "T00:00:00]"
e = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 6, False), "yyyy-mm-dd") & "T00:00:00]"
f = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 7, False), "yyyy-mm-dd") & "T00:00:00]"
g = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 8, False), "yyyy-mm-dd") & "T00:00:00]"
ActiveSheet.PivotTables("PivotTable3").PivotFields( _
"[PO Details].[PO Receipt].[PO Receipt]").VisibleItemsList = Array(a, b, c, d, e, f, g)
End Sub
Can someone help me out?
Dan
I've managed to filter OLAP Pivots before if the CurrentFieldName was one option. Now, I have a range of dates that cannot be selected using the between function because the OLAP Cube isn't set up that way. I've set up a date table in my workbook that has all the possible dates between a selected range from a combox in my userform.
The trick is that not all dates will be in the Cube. So I'm hoping to skip the ones that aren't in the pivot until the macro loops through all of my array.
Here is a recorded macro of what I would like to do:
Sub Macro4()
ActiveSheet.PivotTables("PivotTable3").PivotFields( _
"[PO Details].[PO Receipt].[PO Receipt]").VisibleItemsList = Array( _
"[PO Details].[PO Receipt].&[2015-01-06T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-07T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-08T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-09T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-10T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-12T00:00:00]", _
"[PO Details].[PO Receipt].&[2015-01-13T00:00:00]")
End Sub
My attempt is the following but it doesn't handle errors (Date not in cube)
Sub Macro3()
Dim a, b, c, d, e, f, g As String
a = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 2, False), "yyyy-mm-dd") & "T00:00:00]"
b = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 3, False), "yyyy-mm-dd") & "T00:00:00]"
c = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 4, False), "yyyy-mm-dd") & "T00:00:00]"
d = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 5, False), "yyyy-mm-dd") & "T00:00:00]"
e = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 6, False), "yyyy-mm-dd") & "T00:00:00]"
f = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 7, False), "yyyy-mm-dd") & "T00:00:00]"
g = "[PO Details].[PO Receipt].&[" & Format(Application.WorksheetFunction.VLookup(UserForm1.CBDate.Value, Sheets("Lookup").Range("D:K"), 8, False), "yyyy-mm-dd") & "T00:00:00]"
ActiveSheet.PivotTables("PivotTable3").PivotFields( _
"[PO Details].[PO Receipt].[PO Receipt]").VisibleItemsList = Array(a, b, c, d, e, f, g)
End Sub
Can someone help me out?
Dan