Results 1 to 9 of 9

how can i create a macro for creating a pivot table.

Threaded View

shekar goud how can i create a macro for... 09-18-2008, 06:45 AM
Andy Pope Perhaps some detail on the... 09-18-2008, 06:59 AM
shekar goud Hi Andy, Iam begginer to... 09-18-2008, 07:08 AM
Andy Pope which line in your code? ... 09-18-2008, 07:14 AM
shekar goud Hi Andy, I just tried to... 09-18-2008, 07:27 AM
Andy Pope where would I find this... 09-18-2008, 07:37 AM
shekar goud Hi Andy, Please find... 09-18-2008, 07:44 AM
Andy Pope The data source in your code... 09-18-2008, 08:07 AM
shekar goud Brillant thanks very much... 09-18-2008, 08:27 AM
  1. #1
    Forum Contributor
    Join Date
    09-18-2008
    Location
    india
    Posts
    158

    how can i create a macro for creating a pivot table.

    Hi,

    I have data in sheet1 called "Daily data" and in the next sheet the pivot should be create and there starts my problem.... I have to put "Region","Function",and "Manager" in the row fileds of Pivot and in column the count.

    I have to put filter on Row Pivot Fileds for Region and unselect all feilds execpt "Stamford" and likewise for Function only "Repo".

    I Have no idea but just recorded a macro is giving an error.

    Please help me out ..would be Highly Appreciated.
    Sub BES()
    Dim pt As PivotTable
    Dim pi As PivotItem
        Cells.Select
          ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
            "'Daily Data'!C2:C17").CreatePivotTable TableDestination:="", TableName:= _
            "my pivot", DefaultVersion:=xlPivotTableVersion10
        Set pt = ActiveSheet.PivotTables("my pivot")
         ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)
        ActiveSheet.Cells(3, 1).Select
        ActiveWorkbook.ShowPivotTableFieldList = True
        With ActiveSheet.PivotTables("my pivot").PivotFields("Region")
            .Orientation = xlRowField
            .Position = 1
        End With
        With ActiveSheet.PivotTables("my pivot").PivotFields("GCMM  Function")
            .Orientation = xlRowField
            .Position = 2
        End With
        With ActiveSheet.PivotTables("my pivot").PivotFields("Collateral Manager ")
            .Orientation = xlRowField
            .Position = 3
        End With
        ActiveSheet.PivotTables("my pivot").AddDataField ActiveSheet.PivotTables( _
            "my pivot").PivotFields("Ref Ccy"), "Count of Ref Ccy", xlCount
        With ActiveSheet.PivotTables("my pivot").PivotFields("Region")
            .PivotItems("Houston").Visible = False
            .PivotItems("London").Visible = False
            .PivotItems("Singapore").Visible = False
            .PivotItems("Tokyo").Visible = False
            .PivotItems("Zurich").Visible = False
            .PivotItems("(blank)").Visible = False
        End With
        With ActiveSheet.PivotTables("my pivot").PivotFields("GCMM  Function")
            .PivotItems("OTC").Visible = False
            .PivotItems("(blank)").Visible = False
        End With
        ActiveSheet.PivotTables("my pivot").PivotSelect _
            "'GCMM  Function'[All;Total]", xlDataAndLabel, True
        Selection.Delete
        Range("A9:D10").Select
        Range("D9").Activate
        With Selection.Interior
            .ColorIndex = 15
            .Pattern = xlSolid
        End With
        Range("A3:D4").Select
        Range("D4").Activate
        With Selection.Interior
            .ColorIndex = 15
            .Pattern = xlSolid
        End With
        Range("A9:D10").Select
        Range("D10").Activate
        Selection.Font.Bold = True
        Range("A3:D4").Select
        Range("D4").Activate
        Selection.Font.Bold = True
        Range("G7").Select
    End Sub
    Thanks for any Help....
    Last edited by VBA Noob; 09-18-2008 at 08:30 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. pivot table within macro
    By LiamF in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-20-2008, 01:23 PM
  2. Create a pivot table in a macro
    By Excelliarmus in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-04-2008, 12:17 PM
  3. Macro to drill down for pivot table
    By yeaster in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-13-2008, 12:51 PM
  4. Pivot table or macro for stock layout
    By dhbyrne in forum Excel General
    Replies: 10
    Last Post: 09-15-2007, 05:21 PM
  5. macro to open out pivot table results?
    By Bill-E-BoB in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-07-2007, 01:26 PM

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