+ Reply to Thread
Results 1 to 15 of 15

Pivot Chart Macro Question

  1. #1
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Pivot Chart Macro Question

    Hey Guys!

    Im trying to do a Macro to post a chart from a pivot table ( i used record macro first to understand what was being done). One problem through i cannot get the row variable in the pivot table to be correct, (highlighted in black) I think it has something to do with the dynamic range.... thanks for the help guys

    Sub Macro5()
    '
    ' Macro5 Macro
    '


    '
    Range("A2:AD2").Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range("A2:AD2206").Select

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
    "TotalGama c Sku!R2C1:R2206C30", Version:=xlPivotTableVersion14). _
    CreatePivotTable TableDestination:="", TableName:="PivotTable4" _
    , DefaultVersion:=xlPivotTableVersion14

    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlColumnClustered




    ActiveChart.SetSourceData Source:=Range("Sheet6!$A$1:$C$18")
    ActiveSheet.Shapes("Chart 1").IncrementLeft 192
    ActiveSheet.Shapes("Chart 1").IncrementTop 15
    With ActiveSheet.PivotTables("PivotTable4").PivotFields("DC")
    .Orientation = xlRowField
    .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable4").PivotFields( _
    "Categorização Margem Son")
    .Orientation = xlColumnField
    .Position = 1
    End With
    ActiveSheet.PivotTables("PivotTable4").AddDataField ActiveSheet.PivotTables( _
    "PivotTable4").PivotFields("Categorização Margem Son"), _
    "Count of Categorização Margem Son", xlCount
    End Sub

  2. #2
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Pivot Chart Macro Question

    Hi,

    Your code should be pasted under code tag.However please see below codes.

    Please Login or Register  to view this content.
    Here you can do one thing.. use the following code......

    Please Login or Register  to view this content.
    If your question is resolved, mark it SOLVED using the thread tools. Click on the star if you think some-1 helped you.
    Lokesh Kumar
    Stay Hungry.. Stay Foolish..
    _________________________________________________________
    Please Click STAR to Add Reputation if my/someone's answer helped!

  3. #3
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    Hey!

    GIve error 438 :/

  4. #4
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Pivot Chart Macro Question

    could you upload the workbook with the code........

  5. #5
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    thank you for the promt replys

    When you talk about the workbook, you mean the actual excel file? the complete code is in the first post, please let le me know what you need

  6. #6
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Pivot Chart Macro Question

    This code will not work until I have the data.....

    I do not have the data in new workbook.....
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    Hey no problem!

    One thing though the forum doesnt let me uplaod files :/

  8. #8
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Pivot Chart Macro Question


  9. #9
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question


  10. #10
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    Thank you so much for the help

    Wanted I wanted to do is to put DC in the axis elgend and Cat Margem SOn in the Legend & value section

    I had to delete the other informatio as the analysis is of sensative nature but dont take me wrong

  11. #11
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    Here is the file!
    Attached Files Attached Files

  12. #12
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Pivot Chart Macro Question

    I understand it ........
    But I really do not able to get on what data you have recorded above mentioned macro.....
    anyways try this......not sure..
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    so strange, the code came from record macro... still not working but thank you for the help

  14. #14
    Forum Contributor LokeshKumar's Avatar
    Join Date
    03-31-2015
    Location
    India
    MS-Off Ver
    All, mostly 2010 now..
    Posts
    471

    Re: Pivot Chart Macro Question

    Hey
    Your issue with switching the sheets....since you have switch the sheet so macro is not constant......

  15. #15
    Registered User
    Join Date
    04-27-2015
    Location
    196
    MS-Off Ver
    2003
    Posts
    9

    Re: Pivot Chart Macro Question

    the sheet will always change no, if I create multipel pivot tables?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel 2007 : Pivot chart question
    By derpotheman in forum Excel General
    Replies: 0
    Last Post: 01-27-2011, 04:38 PM
  2. Pivot Chart Question
    By lasadajohnson in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-31-2009, 04:01 PM
  3. Pivot Chart Question....
    By AndreLaplume in forum Excel General
    Replies: 0
    Last Post: 08-30-2006, 11:38 AM
  4. Pivot chart question
    By Sunryzz in forum Excel General
    Replies: 1
    Last Post: 07-10-2006, 02:44 PM
  5. [SOLVED] Pivot Chart Question
    By Renee in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-02-2005, 01:50 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