Souljacked
New Member
- Joined
- Jul 15, 2011
- Messages
- 8
Hello,
I have a functioning array that generates dates from a start date to end date. The array is then passed to the pivot table and everything functions correctly.
However occasionally there are dates generated that are not included in my pivot table and when the routine trys to select them I get an error.
What I want to do is when a pivot item does not exist, the routine will just carry on and try to apply the remaining values in the array.
I've tried to read around the subject but so far found no solutions.
Can anyone help?
Cheers,
Souljacked
I have a functioning array that generates dates from a start date to end date. The array is then passed to the pivot table and everything functions correctly.
However occasionally there are dates generated that are not included in my pivot table and when the routine trys to select them I get an error.
What I want to do is when a pivot item does not exist, the routine will just carry on and try to apply the remaining values in the array.
I've tried to read around the subject but so far found no solutions.
Can anyone help?
Code:
'create trade date array
numDays = enDate - stDate
ReDim dateArr_TradeDate(numDays + 1)
dateArr_TradeDate(0) = "[Trade Date].[Year - Quarter - Month - Date].[Year].&[20" & Right(stDate, 2) & _
"].&[" & Application.WorksheetFunction.RoundUp(month(stDate) / 3, 0) & "].&[" & (Mid(stDate, 4, 2) * 1) & _
"].&[20" & Right(stDate, 2) & "." & Mid(stDate, 4, 2) & "." & Left(stDate, 2) & "]"
For x = 1 To numDays
dateArr_TradeDate(x) = "[Trade Date].[Year - Quarter - Month - Date].[Year].&[20" & Right(stDate + x, 2) & _
"].&[" & Application.WorksheetFunction.RoundUp(month(stDate + x) / 3, 0) & "].&[" & (Mid(stDate + x, 4, 2) * 1) & _
"].&[20" & Right(stDate + x, 2) & "." & Mid(stDate + x, 4, 2) & "." & Left(stDate + x, 2) & "]"
Next x
Code:
'set trade date criteria
pt.PivotFields("[Trade Date].[Year - Quarter - Month - Date].[Date]").VisibleItemsList = _
Array(dateArr_TradeDate())
Cheers,
Souljacked