+ Reply to Thread
Results 1 to 3 of 3

SetElement doesn't work for data labels only

  1. #1
    Registered User
    Join Date
    09-17-2020
    Location
    HK
    MS-Off Ver
    360
    Posts
    5

    SetElement doesn't work for data labels only

    pastebin.ubuntu. com/p/DWRhhjg33B/

    I recorded the macro, made it leaner, ran it on a different chart, and now the setelement for data labels doesn’t work, although the one for grid lines work perfectly.

    1004: Method ‘SetElement’ of object ‘_chart’ failed. Idk how that could happen when the code is literally recorded.

    'error: method 'SetElement' of object '_chart' failed

    'ver 1
    With ActiveChart
    .Legend.Format.TextFrame2.TextRange.Font.Size = 7
    .SetElement (msoElementPrimaryValueGridLinesMajor)
    .SetElement (msoElementDataLabelOutSideEnd)
    .FullSeriesCollection(2).DataLabels.Position = xlLabelPositionCenter
    .FullSeriesCollection(1).DataLabels.Delete
    End With

    'ver 2
    With ActiveChart
    .Legend.Format.TextFrame2.TextRange.Font.Size = 7
    .SetElement (msoElementPrimaryValueGridLinesMajor) 'And (msoElementDataLabelOutSideEnd)
    .FullSeriesCollection(2).DataLabels.Position = xlLabelPositionCenter
    .FullSeriesCollection(1).DataLabels.Delete
    End Wit
    Last edited by KTam169; 09-27-2020 at 02:33 AM.

  2. #2
    Forum Contributor
    Join Date
    05-10-2012
    Location
    Paris, France
    MS-Off Ver
    2016/365
    Posts
    123

    Re: SetElement doesn't work for data labels only

    Hi KTam169

    Why don't you put your code on this forum?

    If you are satisfied with my answer, please add reputation

  3. #3
    Registered User
    Join Date
    09-17-2020
    Location
    HK
    MS-Off Ver
    360
    Posts
    5
    Quote Originally Posted by BrianM45 View Post
    Hi KTam169

    Why don't you put your code on this forum?

    Done, please check it out!!

+ 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. Macro to add Data Labels in all charts available in the whole work book?
    By D2S in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2017, 12:29 PM
  2. Wildcard search in VBA doesn't seem to work on some data
    By Amita68 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-25-2017, 05:38 PM
  3. Data validation doesn't work
    By SuuzyQ in forum Excel General
    Replies: 4
    Last Post: 04-14-2016, 08:18 AM
  4. Help: FillDown doesn't work properly when only one line of data
    By Figgylynn1023 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2011, 05:07 PM
  5. Vlookup doesn't work with imported data
    By surfthenet in forum Excel General
    Replies: 2
    Last Post: 08-24-2010, 10:18 AM
  6. Chart.Labels.Add function doesn't work in excel 2007
    By narek1 in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 03-11-2010, 06:40 AM
  7. Data Validation doesn't work on 1 sheet only
    By lunker55 in forum Excel General
    Replies: 4
    Last Post: 02-25-2005, 02:06 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