+ Reply to Thread
Results 1 to 5 of 5

Fix data labels overlapping in line chart

  1. #1
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Fix data labels overlapping in line chart

    I am using a piece of code from Ron deBruin to add the last point data label in line chart that works just fine. Then, I have the following piece of code that should align the datalabels in case of overlapping(works in 60% of the cases). Is there a better way to fix this? Preferably to be shown to the right side of the line one under each other.
    Thanks

    Please Login or Register  to view this content.
    Click the * to say thanks.

  2. #2
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Fix data labels overlapping in line chart

    Looking online, I found this code, but it doesn't work either and I have no idea on how to change it to do so. Error in red
    Please Login or Register  to view this content.

  3. #3
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,606

    Re: Fix data labels overlapping in line chart

    Hi Paul,

    You've posted no sample file :-P so I prepared one probably oversimplified one for myself.
    This is almost for sure not a final solution, but could contribute a bit towards it.
    The code shall move labels to be located in equal distances.
    If it works with your file then instead of moving all labels to equal distances you could move onle these which are too close to other ones.

    give it a try, it's based on your code (I optimized it just a bit - removed GoTo statements as regular If did the job well and used looping through charts collection).

    Please Login or Register  to view this content.
    Best Regards,

    Kaper

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,606

    Re: Fix data labels overlapping in line chart

    The issue with the second code you posted is because in main sub you loop through all points in series 1, while (if I uderstood you well) the labels are only at last data points. so the first points of each series has no labels, so their labels left position is not defined
    And you try to compare "not defined position" with "not defined position".

    Try if this works better (I have not changed main loop into looping through collection elements here, but would normally do):

    Please Login or Register  to view this content.

  5. #5
    Forum Expert PaulM100's Avatar
    Join Date
    10-09-2017
    Location
    UK
    MS-Off Ver
    Office 365
    Posts
    2,108

    Re: Fix data labels overlapping in line chart

    You sir, are a legend! is the best solution ever. Many thanks for your help.

+ 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. Data Labels overlapping in XY Scatter chart
    By MagicMan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2018, 12:25 PM
  2. [SOLVED] Line chart with two lines and hidden data labels
    By Kagesen in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-26-2018, 06:19 AM
  3. Pivot Chart Overlapping Axis labels
    By unsalted in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 07-22-2015, 08:44 PM
  4. Extra Set of Data Labels in Line Chart?
    By dsfcom in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-15-2012, 07:51 AM
  5. Line Chart and Data Labels
    By gballard in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-26-2012, 06:49 PM
  6. Second Line away from 0 and 3 data labels per chart row
    By nickFe in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-20-2011, 09:17 PM
  7. Data labels on Line chart
    By R in forum Excel General
    Replies: 4
    Last Post: 04-02-2006, 12:50 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