+ Reply to Thread
Results 1 to 3 of 3

Get Range for Chart DataLabels when using “Value From Cells” (Series.DataLabels.ShowRange)

  1. #1
    Registered User
    Join Date
    03-17-2020
    Location
    Midlands, UK
    MS-Off Ver
    2016
    Posts
    2

    Get Range for Chart DataLabels when using “Value From Cells” (Series.DataLabels.ShowRange)

    I have a complex workbook that's "evolved" over time and I'm trying to update it. However, it has many charts which are driven from data from across the workbook and I wanted the ability to easily identify what source ranges are associated with each chart (ie, highlighting all the Chart Precedents). I've probably re-invented the wheel but I’ve created some code which goes through each chart and highlights the associated ranges by drawing a textbox overlaying each of the ranges used within the charts (with the chart and series names in the text box). This highlights (using different colours) the Value, Axis and Label ranges and also a range for the Title if it references a cell.

    There is, however, one bit that I cannot get to work. It's possible to set an alternate range for Data Labels of a Chart where the option is selected to get the "Values From Cells" (the VBA flag for which is "ser.DataLabels.ShowRange").

    After much googling there's many references to creating the range (with the rather convoluted "Series.DataLabels.Format.TextFrame2.TextRange. InsertChartField") but I can't find any references to reading the range.

    The code I’ve got so far seems to be working well but I’ve just got some temporary code for the Alternate DataLabel Range which overlays a text box directly on any chart that has an Alternate DataLabel Range so at least I know which charts have such a range defined.

    I would like to share the code but, in its commented form, it’s about 16,000 chars so won’t fit. Also, being new to the forum I’m not yet allowed to post the workbook - as soon as I can I will.

    If anybody knows how to get the range associated with ser.DataLabels.ShowRange I'd appreciate it and I'll be able make the utility a bit more universal. (I'm also prepared for the responses that tell me that I've wasted my time and that there’s already an in-build function for this in Excel! - no worries, I've enjoyed the coding )

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

    Re: Get Range for Chart DataLabels when using “Value From Cells” (Series.DataLabels.ShowRa

    I don't believe there is any code to get it directly, unless the data label was manually set to reference a cell.

    The Formula property only returns the contents of the cell not the actual cell address.
    You can get at the information if you trawl through the charts xml. but that is not easy to do as you have to create a copy of the file, convert to zip, unpack it and then local the appropriate chart xml before finally locating the dataLabelrange.

    The same sort of issue applies to error bar custom values

    You should be able to post a workbook if you follow the instructions in the yellow banner at the top of the thread.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    03-17-2020
    Location
    Midlands, UK
    MS-Off Ver
    2016
    Posts
    2

    Re: Get Range for Chart DataLabels when using “Value From Cells” (Series.DataLabels.ShowRa

    Thanks Andy, I was thinking that it may not be possible.

    Attached is the workbook as it stands. It's done what I needed it for - I was just hoping the make it more comprehensive. I hadn't consider error bar values so it doesn't look for those..
    Attached Files Attached Files

+ 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. How to set zOrder for datalabels in Chart?
    By Mohanv23 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-05-2013, 06:55 AM
  2. best way to temporarily hide chart datalabels
    By desertsp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2013, 06:06 PM
  3. Datalabels in chart
    By prefix in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2010, 08:02 AM
  4. Bubble chart datalabels
    By rvExcelNewTip in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 07-18-2007, 09:25 AM
  5. [SOLVED] Chart Datalabels.Position
    By Michael Singmin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-12-2005, 03:15 PM
  6. [SOLVED] Lock the chart but leave datalabels position editable
    By Joy in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-13-2005, 04:05 PM
  7. Be able to edit position of datalabels in a protected chart.
    By Joy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-13-2005, 04:05 PM
  8. [SOLVED] How to assign datalabels to a scatter chart, obtaining the labels.
    By Jos Koot in forum Excel General
    Replies: 1
    Last Post: 04-22-2005, 08:06 AM

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