+ Reply to Thread
Results 1 to 4 of 4

Labels for horizontal points

  1. #1
    Forum Contributor
    Join Date
    01-07-2006
    Location
    San Jose, CA
    MS-Off Ver
    2007, 2016
    Posts
    115

    Labels for horizontal points

    Hi,

    I have a worksheet that uses VBA code to label data points. (many thanks to Jon Peltier) It works fine for the vertical data points, however, there are data points along the x axis where the y value =0. These labels should be placed above these data points, not to the right.

    Also, if the first x axis data were placed above that point, it would run into the y data point above. I need a solution for that as well.

    Could anyone in the Forum modify the VBA code to fix these problems?

    Any help is greatly appreciated.

    Thanks,

    Art
    Attached Files Attached Files

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Labels for horizontal points

    If you change this line from this

    .Position = xlLabelPositionright to this

    .Position = xlLabelPositiontop you'll change the labelling position. The macro gives you the choice to be selective in which labels you choose so I changed the macro and ran it just on the one's I wanted to be above and it worked fine.

    If you want the macro to automatically change to right or top depending on it's location to other points then that's going to be a bit more coding
    Happy with my advice? Click on the * reputation button below

  3. #3
    Forum Contributor
    Join Date
    01-07-2006
    Location
    San Jose, CA
    MS-Off Ver
    2007, 2016
    Posts
    115

    Re: Labels for horizontal points

    Hi Crooza,

    Thanks for your response and comments. In looking at the chart again, I realize that I need some some labels to the right, some to the left and some above based on the chart data. Do you know how to modify the VBA code to allow selection of label placement based on data range?

    Thanks,

    Art

  4. #4
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Labels for horizontal points

    OK. I haven't forgotten you. There's a bit of coding required to do this. I thought there was a xlLabelpositionbestfit but doesn't seem to work or be available to me so I've worked out a way to try and best fit all the labels so they are placed in the location where there is the greatest space.

    To do this I used some helper columns and ideally in time I'll get around to hardcoding these helper columns into the macro but in the meantime I'm using 4 columns to do some array calculations to find where the nearest other points are in relation to the reference points location (ie above, below, right or left of the reference point). I then look for the greatest space and place the text on that side. It doesn't take into account where text from other points might interfere so it is very basic but it works to a degree. I tried it on both your data (attached) and also on some random data sets and it does appear in most cases to 'clean up' the labelling.

    Try the attached file and run the macro for yourself. If and when I get all the helper columns hardcoded I'll upload that too.

+ 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. Scatter Chart Horizontal Labels
    By Spmurphy in forum Excel General
    Replies: 2
    Last Post: 06-30-2014, 01:28 PM
  2. Horizontal Axis Labels not showing
    By javeds in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-07-2014, 09:59 PM
  3. [SOLVED] modifying the Horizontal axis labels
    By Elainefish in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-16-2013, 05:02 PM
  4. [SOLVED] Omit horizontal axis points if data=0
    By gugg7378 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-04-2012, 01:06 AM
  5. How To Get Y Axis Labels Horizontal?
    By mycon73 in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 09-30-2011, 11:26 AM
  6. Horizontal axis labels in Bar Charts
    By jeskit in forum Excel General
    Replies: 2
    Last Post: 08-15-2011, 04:39 AM
  7. Two rows of labels on the horizontal axis
    By macaonghus in forum Excel General
    Replies: 0
    Last Post: 01-12-2010, 06:49 PM
  8. labels for chart data points
    By riwiseuse in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 12-01-2008, 03:44 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