Results 1 to 3 of 3

Macro to Resize and Position Pivot Chart

Threaded View

  1. #1
    Registered User
    Join Date
    01-25-2011
    Location
    Miami
    MS-Off Ver
    Office 365
    Posts
    11

    Macro to Resize and Position Pivot Chart

    This is killing me. I have created this macro to develope a pivot chart with some formats but I cannot increase the size and position it to where I would like to .

    Below you can see my attempt from pressing record Macro:

    Sub InsertGraph1()
    '
    ' InsertGraph1 Macro
    '
    
    '
        Range("B19").Select
        ActiveSheet.Shapes.AddChart.Select
        ActiveChart.SetSourceData Source:=Range( _
            "'Supplier Order Fulfillment'!$B$10:$C$20")
        ActiveWorkbook.ShowPivotChartActiveFields = True
        ActiveChart.ChartType = xlColumnClustered
        ActiveWorkbook.ShowPivotChartActiveFields = False
        ActiveChart.Location Where:=xlLocationAsObject, Name:= _
            "Supplier Order Fulfillment"
        ActiveChart.ClearToMatchStyle
        ActiveChart.ChartStyle = 32
        ActiveChart.ClearToMatchStyle
        ActiveWorkbook.ShowPivotTableFieldList = False
        ActiveChart.ChartTitle.Select
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.ChartTitle.Text = "Monthly Supplier Order Fullfilment"
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.ChartArea.Select
        ActiveChart.SetElement (msoElementLegendNone)
        ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.SeriesCollection(1).DataLabels.Select
        ActiveSheet.ChartObjects("Chart 1").Activate
        ActiveChart.ChartArea.Select
        Range("B35").Select
        ActiveWindow.ScrollRow = 4
        ActiveWindow.ScrollRow = 5
        ActiveWindow.ScrollRow = 6
        ActiveWindow.ScrollRow = 7
        ActiveWindow.ScrollRow = 8
        ActiveWindow.ScrollRow = 9
        ActiveWindow.ScrollRow = 10
        ActiveWindow.ScrollRow = 11
        ActiveWindow.ScrollRow = 12
        ActiveWindow.ScrollRow = 13
        ActiveWorkbook.ShowPivotTableFieldList = True
        ActiveSheet.PivotTables("PivotTable2").AddDataField ActiveSheet.PivotTables( _
            "PivotTable2").PivotFields("Qty Rcpt"), "Sum of Qty Rcpt", xlSum
        Columns("D:D").Select
        Range("D13").Activate
        Selection.NumberFormat = "#,##0"
        Range("B33").Select
        Selection.Copy
        Range("C33:D33").Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        Range("B33").Select
        Selection.Copy
        Range("B32").Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        Selection.Copy
        Range("C32:D32").Select
        Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        Application.CutCopyMode = False
        Range("C35").Select
        ActiveSheet.Shapes.AddChart.Select
        ActiveChart.SetSourceData Source:=Range( _
            "'Supplier Order Fulfillment'!$B$32:$D$38")
        ActiveWorkbook.ShowPivotChartActiveFields = True
        ActiveChart.ChartType = xlColumnClustered
        ActiveWorkbook.ShowPivotChartActiveFields = False
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).AxisGroup = 2
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(1).Select
        ActiveChart.SeriesCollection(1).ChartType = xlLineMarkers
        ActiveChart.ApplyLayout (4)
        ActiveChart.ClearToMatchStyle
        ActiveChart.ChartStyle = 26
        ActiveChart.ClearToMatchStyle
        ActiveChart.ApplyLayout (9)
        ActiveChart.SetElement (msoElementLegendBottom)
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.ChartTitle.Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.ChartTitle.Text = "YTD Supplier Order Fullfilment"
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.ChartArea.Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).DataLabels.Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).Select
        ActiveChart.SetElement (msoElementDataLabelInsideBase)
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(2).DataLabels.Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(1).DataLabels.Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(1).Select
        ActiveChart.SetElement (msoElementDataLabelRight)
        ActiveChart.SetElement (msoElementDataLabelTop)
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.SeriesCollection(1).DataLabels.Select
        ActiveSheet.ChartObjects("Chart 2").Activate
        ActiveChart.ChartArea.Select
    End Sub
    Theres two pivots and two Pivot Charts. I would like to have Chart 2 positioned with a range of B32:M46 and Chart 1 positioned ranged E2:M20

    Can anyone help?
    Last edited by rezolutions24; 04-06-2011 at 02:00 PM.

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