+ Reply to Thread
Results 1 to 2 of 2

Grabbing the next column value in a pivot table

  1. #1
    Alexandre
    Guest

    Grabbing the next column value in a pivot table

    Hey i am currently using the following code,
    and I would like to sum the values which are in the second column, i am
    currently evaluating the first column,

    ==>

    Sub PivotShowItemAllVisible()

    Dim pt As PivotTable
    Dim pf As PivotField
    Dim pi As PivotItem
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    On Error Resume Next

    Set pt = ActiveSheet.PivotTables("months_to_incorp_pivot")

    Dim ECWI3Months As Integer
    ECWI3Months = 0

    For Each pf In pt.RowFields
    pf.AutoSort xlManual, pf.SourceName
    For Each pi In pf.PivotItems
    Application.StatusBar = "Evaluating : " & pi.Name
    If (pi.Value <= 3) Then
    <==
    THIS is where i want to sum the second column
    ==>

    ECWI3Months = pi.Value + ECWI3Months
    End If

    pi.Visible = True
    Next pi
    Next pf
    ActiveSheet.Range("D4:D4").Value = ECWI3Months
    ActiveSheet.Range("B4:B4").Value = pt.GetData(pt.GrandTotalName)
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
    End Sub

    <==

    Using the folowing code how would i go about doing this ?


    Regards,
    Alexandre Brisebois


  2. #2
    Alexandre
    Guest

    Re: Grabbing the next column value in a pivot table

    for anyone else woundering

    using this line does the trick
    ECWI3Months = pi.DataRange.Value + ECWI3Months

    PivotItem.DataRange.Value


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1