Consulting

Results 1 to 8 of 8

Thread: Custom scale in chart

  1. #1

    Custom scale in chart

    Hi everybody, I am trying to customize my "x" axis in a chart, this axis contains years and "y" axis contains the number of events. So what I am trying to do is to start my "x" axis in the year 1904, then the next year should be 1910, 1920, 1930.....2013. I must use this specific interval, it must start in 1904, the next value 1910 adding 10 years at a time till 2013 exactly. I've been trying with this VBA code:


    Sub ScaleAxes()
    With Application.ActiveChart.Axes(xlCategory, xlPrimary)
    .MinimumScale = ActiveSheet.Range("t3").Value
    .MaximumScale = ActiveSheet.Range("t15").Value
    .MajorUnit = ActiveSheet.Range("t17").Value
    .DisplayUnit = ActiveSheet.Range("t15").Value
    End With


    End Sub


    But this only helps me to set the minimun and maximum I am still trying to figure how to start the sum in 1910.... The final scale should look like this:

    1904,1910, 1920.....2013

    THANKS IN ADVANCE

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Supply a file with your chart and its data for us to experiment with - it'll answer quite a lot questions about how you've set it up.

    ps. Finding this difficult in Excel 2010 with an xy scatter chart so far… What's your version of Excel and are those years actual Excel dates in the sheet?
    Last edited by p45cal; 06-10-2017 at 05:46 AM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Must the X axis spacing be proportionate? Have a look at this
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    You can do something like this but it's not especially easy:
    Attachment 19456
    Attached Images Attached Images
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    @Slashilboy.... posted this issue anywhere else recently?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    foro.jpg
    Here is an image of my graph, I hope this will help us to solve the initial problem

  7. #7
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,875
    Quote Originally Posted by slashiiboy View Post
    Here is an image of my graph, I hope this will help us to solve the initial problem
    Not at all.
    1. Supply a file (not a picture of a file) with your chart and its data for us to experiment with - it'll answer quite a lot questions about how you've set it up.
    2. Answer the questions that people who are trying to help you ask.
    3. In msg#5, Aussiebear asked you about posting elsewhere (you have); please have a read of http://www.excelguru.ca/content.php?184, then post links to those posts.

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,058
    Location
    @slashilboy Since you appear to be ignoring my question, I shall put your thread on hold until you pm me with your responce.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •