I'm using VB6 and want to set the value in a slicer on an .xls sheet.
If I use this code:
'first, set Slicer_Date1 to today's date (or passed in date)
Dim sC As SlicerCache
Set sC = ActiveWorkbook.SlicerCaches("Slicer_Date1")
sC.SlicerItems("7/5/2013").Selected = True
It runs as expected.
If I try to replace the "7/5/2013" with a variable however, I get "Run Time error 5 - invalid procedure call or argument" on line 5 below.
1 Dim sDateToUse As String
2 sDateToUse = Format(Now, "m/d/yyyy")
3 Dim sC As SlicerCache
4 Set sC = ActiveWorkbook.SlicerCaches("Slicer_Date1")
5 sC.SlicerItems(sDateToUse).Selected = True
putting another set of double quotes around sDateToUse
putting brackets around sDateToUse (found that out on the web somewhere)
passing sDateToUse in as a date
forcing sDateToUse = "7/5/2013" to be sure it wasn't a data issue
None of the above work.
Can some one help me ID what I'm missing?
Thanks so much!