+ Reply to Thread
Results 1 to 11 of 11

Aligning horizontal 0 axis, chart with two axis

  1. #1
    Registered User
    Join Date
    09-12-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    41

    Aligning horizontal 0 axis, chart with two axis

    I have a chart with two axis. One showing value and one showing percent. When the curve or column goes of the chart I update the scale but then the category axis is not aligned (0 value and 0% is not on the same horisontal axis any longer). I then need to recalculate and manually adjust the scale to have 0 on same horisontal axis.

    Is there any way of having this done automatically, it's currently not an optimal situation since it's time consuming to correct all the charts (the original file has many charts).

    Attached is an example with data sheets and chart sheet.

    Regards,
    Niklas

    Financial Analyst

    Using:
    Excel 2003, Win XP
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Aligning horisonatal 0 axis, chart with two axis

    http://peltiertech.com/Excel/Charts/AlignXon2Ys.html
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    09-12-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Aligning horisonatal 0 axis, chart with two axis

    Hi Andy,

    Thanks for you reply. Do you know where I can download an example of this. I've tried but I keep getting error code. I would like to see a working example to figure out what I'm doing wrong.

    Rgds
    Niklas

  4. #4
    Registered User
    Join Date
    09-12-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Aligning horisonatal 0 axis, chart with two axis

    I get this error when trying to create a chart just like the one in the example Andy gave me above..

    Compile error:
    Ambiguous name deteced: AlignY_PrimaryMinimium

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Aligning horizontal 0 axis, chart with two axis

    That sounds like you pasted the code twice.

    I simply opened your file. Added a code module and then pasted the code copied from the webpage.

    The I ran AlignY_PrimaryMinimum routine

  6. #6
    Registered User
    Join Date
    09-12-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Aligning horizontal 0 axis, chart with two axis

    I'm really struggeling with this, would it be possible for you to add the code to the file I attached and upload it? It would really help me see what I'm doing wrong.

    Thanks

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Aligning horizontal 0 axis, chart with two axis

    It would make more sense for you to post what you have done so we can see where you are going wrong as both the web page and I have given instructions on how to do it.

  8. #8
    Registered User
    Join Date
    09-12-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Aligning horizontal 0 axis, chart with two axis

    I have attached the file, I pasted the code into the VBA editor, maybe it should be somewhere else?

    Sorry, I feel really stupid, my knowledge in VBA coding is almost zero, but I will soon take a course.

    Any help is appreciated.
    Attached Files Attached Files

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Aligning horizontal 0 axis, chart with two axis

    You did not copy and paste the code that was in the link I posted.

    It was similar but you called all the helper routines

    Please Login or Register  to view this content.
    which is why the ambiguous error is reported.

    Although you can place code in the chart sheet object it is best to place it in a standard code module.

    I have revised your example.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    09-12-2010
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Aligning horizontal 0 axis, chart with two axis

    Thanks Andy

    An additional question....Is the idea to run these macros each time or is it possible to have the alignment done automaically?


    Regards,
    Niklas

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,431

    Re: Aligning horizontal 0 axis, chart with two axis

    The alignment will not happen automatically, you need to run the vba code.

    That said you only need to rerun the code if the data changes such that the axes limits need to be changed.

    You could have the code run automatically when the source data changes by putting event code in the worksheet object and check if the cells changing are those used by the chart.

+ Reply to Thread

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