Consulting

Results 1 to 3 of 3

Thread: Solved: Easy way to group date in Pivot Table

  1. #1
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location

    Solved: Easy way to group date in Pivot Table

    Anybody know an easy way to group the date in a Pivottable with VBA? Right now all I can find is I have to select the column name or one of the dates and then group it. Is there an easier way?

    Daniel

  2. #2
    VBAX Expert
    Joined
    Jul 2004
    Location
    Wilmington, DE
    Posts
    600
    Location
    This appears to work:

    [VBA]
    Dim pf As PivotField

    Set pf = pt.PivotFields("Date")
    pf.LabelRange.Group Start:=7306, End:=73051, Periods:=Array(False, False, False _
    , False, True, False, True)
    [/VBA]

    In my limited testing, that grouped my date field into years and months, with really wide boundaries for the start/end dates.
    Regards,

    Patrick

    I wept for myself because I had no PivotTable.

    Then I met a man who had no AutoFilter.

    Microsoft MVP for Excel, 2007 & 2008

  3. #3
    VBAX Master
    Joined
    Jun 2006
    Posts
    1,091
    Location
    Thank you that worked perfectly

Posting Permissions

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