+ Reply to Thread
Results 1 to 2 of 2

Adjusting Major Units on Pivot Chart with Worksheet_PivotTableChangeSync

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-08-2013
    Location
    London
    MS-Off Ver
    365
    Posts
    136

    Adjusting Major Units on Pivot Chart with Worksheet_PivotTableChangeSync

    Hi All, I'm stuck on the correct way to call "Chart 1" (Pivot Chart) on my worksheet to allow a change of major axis value when filters are changed. I keep getting errors at the red highlighted code. I have this and have tried these and many other arrangements but am getting nowhere.

    Could someone please set me straight?

    Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
    
        Dim mUnit As Long
    
        If Cells(LastRow, LastCol) / LastCol - 1 >= 30 Then
            mUnit = 10
        Else
            If Cells(LastRow, LastCol) / LastCol - 1 >= 200 Then
                mUnit = 50
            Else
                If Cells(LastRow, LastCol) / LastCol - 1 >= 500 Then
                    mUnit = 100
                End If
            End If
        End If
    
        ActiveSheet.ChartObjects(1).Chart.Axes(xlValue).MajorUnit = mUnit
    
        'or
    
        ActiveSheet.Shapes("Chart 1").Axes(xlValue).MajorUnit = mUnit
    
    End Sub
    Many thanks,
    Dave C

  2. #2
    Forum Contributor
    Join Date
    10-08-2013
    Location
    London
    MS-Off Ver
    365
    Posts
    136

    Re: Adjusting Major Units on Pivot Chart with Worksheet_PivotTableChangeSync

    I got around this by setting the MajorUnit to Auto and adjusting the MinorUnit to 1 when creating the Pivot Chart.

    With ActiveChart
        .Axes().MajorUnitIsAuto = True
        .Axes(xlValue).MinorUnit = 1
    End With
    Many thanks!

+ 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. Replies: 0
    Last Post: 06-20-2017, 10:48 AM
  2. [SOLVED] Help with Private Sub Worksheet_PivotTableChangeSync(ByVal Target As PivotTable)
    By rv02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-06-2016, 12:45 PM
  3. Copy Major Units value from graph
    By dtrom26 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-30-2015, 10:40 AM
  4. major and minor chart units
    By jbates58 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-22-2013, 09:04 AM
  5. Mutliple major units in excel axis
    By karthikcoep in forum Excel General
    Replies: 1
    Last Post: 03-22-2010, 12:04 AM
  6. Setting Major Unit in Chart- can they be set individually
    By ExcelFed in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 12-04-2008, 02:51 PM
  7. defining major units on chart axis
    By Nick Turner in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-31-2005, 03:05 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