Results 1 to 3 of 3

Thread: VBA - Code if pivot column header gets changed every day

  1. #1
    Junior Member
    Join Date
    Mar 2015
    Posts
    3
    Rep Power
    0

    VBA - Code if pivot column header gets changed every day

    hi,

    i want one of the pivot field in data as sum, but that columnheader will be changing every time the users runs the macro.

    is there any solution for this.


    Thanks!

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,122
    Rep Power
    10
    Welcome to board !

    Post your code.
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Junior Member
    Join Date
    Mar 2015
    Posts
    3
    Rep Power
    0
    Sheets.Add
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDa tabase, SourceData:= _
    "Sheet1!R1C1:R19C12", Version:=xlPivotTableVersion12).CreatePivotTable _
    TableDestination:="Sheet4!R3C1", TableName:="PivotTable1", DefaultVersion _
    :=xlPivotTableVersion12
    Sheets("Sheet4").Select
    Cells(3, 1).Select
    With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Region")
    .Orientation = xlRowField
    .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable1").AddDataFiel d ActiveSheet.PivotTables( _
    "PivotTable1").PivotFields("Sum of Feb usd @1.3881 "), _
    "Count of Sum of Feb usd @1.3881 ", xlCount
    With ActiveSheet.PivotTables("PivotTable1").PivotFields ( _
    "Count of Sum of Feb usd @1.3881 ")
    .Caption = "Sum of Sum of Feb usd @1.3881 "
    .Function = xlSum
    End With
    End Sub

    the header "sum of feb usd @1.3881 can change

Similar Threads

  1. Replies: 1
    Last Post: 09-18-2013, 10:17 PM
  2. Replies: 7
    Last Post: 07-19-2013, 12:47 PM
  3. Replies: 17
    Last Post: 12-18-2012, 04:15 PM
  4. VBA Code to create Pivot tables
    By Howardc in forum Excel Help
    Replies: 2
    Last Post: 08-05-2012, 02:41 AM
  5. Pivot Table - Volume by Day and Half Hour
    By Ian Herndon in forum Excel Help
    Replies: 9
    Last Post: 07-07-2012, 10:04 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
  •