Results 1 to 2 of 2

Thread: Displaying Pivot Table items with a loopy loop

  1. #1

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Displaying Pivot Table items with a loopy loop

    So I have a pivot table with a date filter. I want to only display the dates that are within the last 63 days. Sinch! Just a freakin loop adding negatives.

    However, some of these dates have a time after them.

    So what I need to figure out, is can I have some sort of wild card or Left() integrated into the loop.

    Here is what I have, and would work if my data souurce didn't suck.


    Code:
        For i = -1 To -63 Step -1
            ActiveSheet.PivotTables("PivotTable3").PivotFields("LST_XP_DAT").PivotItems(CStr(DateAdd("d", i, Date))).Visible = True
                DoEvents
        Next

  2. #2

    Thread Starter
    Frenzied Member Spajeoly's Avatar
    Join Date
    Mar 2003
    Location
    Utah
    Posts
    1,068

    Re: Displaying Pivot Table items with a loopy loop

    Woohoo, got it. This does exactly what I need so I will post it as an FYI.

    Code:
    Dim PName$()
    
        For i = 1 To 10000
            PName = Split(ActiveSheet.PivotTables("PivotTable3").PivotFields("LST_XP_DAT").PivotItems(i).Name, " ")
                If DateDiff("d", PName(0), Date) <= 0 Then Exit For
                If DateDiff("d", PName(0), Date) < 63 Then ActiveSheet.PivotTables("PivotTable3").PivotFields("LST_XP_DAT").PivotItems(i).Visible = True
                    DoEvents
        Next
    Last edited by Spajeoly; May 2nd, 2008 at 04:41 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width