+ Reply to Thread
Results 1 to 12 of 12

Can Excel automatically insert the column header as the axis title?

  1. #1
    Registered User
    Join Date
    11-23-2012
    Location
    Germany
    MS-Off Ver
    Excel: mac 2011 (14.2.5)
    Posts
    13

    Cool Can Excel automatically insert the column header as the axis title?

    I make tons of scatter plots and I am getting tired of always having to go in and insert the vertical and horizontal axis titles afterwards and writing them.
    Are there a way of Excel automatically including axis titles in all new scatter plots and even better if it could be set per default to use the column header as the axis title?
    This would be such a time saver if it exist.
    (I am using Excel Mac 2011)

    I don't know if a macro can do it.
    I have tried to record one, but even though I have read somewhere that I in the axis title can write "= A1" and then it would write the header in column A, then it doesn't work. And I also don't want it to always be A1 but whatever the column is.
    If I could make my dream macro, I would want to be able to play it, when I have selected two columns. It should make a scatter plot of them, then make axis titles with the column headers, and have the axis titles, axis number and legend increase their size to 14.
    As this is what I do many times a day at the moment.

    Can anyone help?

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Can Excel automatically insert the column header as the axis title?

    Try this

    Please Login or Register  to view this content.

    Open up the VBA editor by hitting ALT F11

    Insert a new module by hitting Insert - Module

    Paste the macro into the empty sheet

    Hit ALT F11 to get back to the worksheet.

    Run the macro by going to tools-macro in Excel 2003 or the view ribbon in Excel 2007/2010.
    Martin

  3. #3
    Registered User
    Join Date
    11-23-2012
    Location
    Germany
    MS-Off Ver
    Excel: mac 2011 (14.2.5)
    Posts
    13

    Re: Can Excel automatically insert the column header as the axis title?

    Thank you Martin, it looks like my dream macro is possible after all. Thanks for taking the time to write this for me.

    I am however running into a compilation error, when I try to run it. It states "Compile error: Argument not optional" and it is highlighting the first line: "Sub CreatScatterChart()". The way I ran it, was that I selected two columns, went to Tools-macro-macros and then selected the CreatScatterChart, and clicked run, and it came up with the error. Does it run without problems when you try to do the same on your computer? Do you have any ideas of how I can get it to work. I have unfortunately never worked with programming in VBA.

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Can Excel automatically insert the column header as the axis title?

    Please see the attached.

    You can run the macro by either hitting the button or pressing Control l (lower case L).
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-23-2012
    Location
    Germany
    MS-Off Ver
    Excel: mac 2011 (14.2.5)
    Posts
    13

    Re: Can Excel automatically insert the column header as the axis title?

    I get the same error no matter what.
    I made a little screen shot video of what I do, hoping that you can see if I do something wrong:
    http://youtu.be/YpxLwP8iUT0
    or what the problem is.
    Thanks again for trying to help me, I really appreciate it

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Can Excel automatically insert the column header as the axis title?

    Just noticed that you are using a Mac - my solution was developed on a Windows machine. Maybe a Mac developer can comment further.

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Can Excel automatically insert the column header as the axis title?

    Can you record a macro creating a chart manually and post the code that is recorded? - it might be possible to see what differences there might be.

  8. #8
    Registered User
    Join Date
    11-23-2012
    Location
    Germany
    MS-Off Ver
    Excel: mac 2011 (14.2.5)
    Posts
    13

    Re: Can Excel automatically insert the column header as the axis title?

    Thanks you for still trying
    I tried to make a macro doing the same by recording what I did, which means it ends up differently. I had to take out part of it afterwards, as it didn't work when I tried to run it.
    When I tried to run yours, it seems like it always hightlights the first line and .Character in the line
    ActiveChart.ChartTitle.Format.TextFrame2.TextRange.Characters.Text = MyTitleL

    I tried to take the line out, and Excel crashed when I try to run it, after I had chosen the range and the title.

    I have tried to line by line to include your into mine, and when I got to the line mentioned above it didn't crash but came with the error
    Run-time error '438': Object doesn't support this property or method.


    This was what I was comparing with. the macro I did:

    Please Login or Register  to view this content.
    Moderator Note:

    Pls use code tags around your code next time as per forum rules.
    Last edited by Fotis1991; 09-20-2013 at 03:17 AM.

  9. #9
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Can Excel automatically insert the column header as the axis title?

    Can you giive this a try ...


    Please Login or Register  to view this content.

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

    Re: Can Excel automatically insert the column header as the axis title?

    haven't got a mac to confirm but will this change the font size of the title?

    Please Login or Register  to view this content.
    Cheers
    Andy
    www.andypope.info

  11. #11
    Registered User
    Join Date
    11-23-2012
    Location
    Germany
    MS-Off Ver
    Excel: mac 2011 (14.2.5)
    Posts
    13

    Red face It is solved

    It's working!!!!!! (Dancing around the office... New office mate looking at me weird)
    Thank you so much for sticking this one out! Just brilliant. Can't believe I am so lucky.

    I also figured out how to change the front size of the axis numbers finally.


    So the final code, that works on mac's look like this:


    Please Login or Register  to view this content.
    Thanks again
    Last edited by galaxytraveler42; 09-20-2013 at 06:16 AM. Reason: Slitting the post in two

  12. #12
    Registered User
    Join Date
    11-23-2012
    Location
    Germany
    MS-Off Ver
    Excel: mac 2011 (14.2.5)
    Posts
    13

    Re: Can Excel automatically insert the column header as the axis title?

    Thanks Andy for looking into my problem, I got the line to work by changing it to:
    Please Login or Register  to view this content.

+ 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. Column Header to = Saved File's Title
    By wmfinance in forum Excel General
    Replies: 4
    Last Post: 08-13-2010, 02:30 PM
  2. Automatically copy row header to column header...
    By Soons in forum Excel General
    Replies: 4
    Last Post: 10-16-2008, 11:38 AM
  3. How to insert superscripted value in Y-axis title of excel sheet
    By kapatia in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 06-18-2006, 03:20 PM
  4. [SOLVED] Can XLS automatically insert file properties fields into a header
    By Margaret Johnson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-31-2006, 10:50 PM
  5. Replies: 1
    Last Post: 06-23-2005, 02:05 PM

Tags for this Thread

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