+ Reply to Thread
Results 1 to 17 of 17

N/A Question for Chart

  1. #1
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    N/A Question for Chart

    Hi All,

    I want to know how do I make it so that for a set of 2 data bars on a chart, if the corresponding cells have N/A values, then it just won't show up on the bars at all. I am sure its just an if statement but not sure how to implement it, any advice would be well appreciated.
    Last edited by Victor Li; 02-06-2018 at 09:58 AM.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,863

    Re: N/A Question for Chart

    I'm not sure it is a simple If statement.

    This is the most comprehensive discussion I know of on "gaps" in charts: https://peltiertech.com/mind-the-gap...g-empty-cells/ For bar and column charts, N/A entries will still be present in the chart. For that matter, just having the category present in the x values range causes there to be category in the chart. It might depend on exactly what you mean by "won't show up on the bars at all". In my experience, the only way to completely remove a category from a bar/column chart is to completely remove the category from the source data. You could use filters which should eliminate categories from the chart, or some kind of helper range where you make copies (by formula or VBA or other means) of all of the real data.

    As suggested, if you will upload a good sample of your data and chart and explain exactly what you want to do, we can be more helpful.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    Hi I have attached my sample workbook, so the goal is to have values on top of the bars for the last 2 set of existing values at all times everytime the chart updates. However, the values should be null or empty when the cell have a value of 0 or N/A.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,444

    Re: N/A Question for Chart

    Did you read post #5? I will remove your latest post until you have addressed that issue.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    ok, here's the link to that other post: https://www.mrexcel.com/forum/excel-...-question.html

  6. #6
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    Is that the one you are talking about?

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,444

    Re: N/A Question for Chart

    Thank you.

    Please read our forum rules before posting again. For your convenience, here is a link to them: https://www.excelforum.com/forum-rul...rum-rules.html

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,444

    Re: N/A Question for Chart

    Quote Originally Posted by Victor Li View Post
    Is that the one you are talking about?
    If there are other forums where you have asked the same question, you need to provide links to those, too. Are there?

  9. #9
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    Nope that's it.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,444

    Re: N/A Question for Chart

    OK - thanks. I've linked to the forum rules in post #7 above so that you can make sure that you don't fall foul of anymore here.

    You do not yet seem to have attached a workbook.

  11. #11
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    I thought I attached it during my previous post, I'll attach it again here.
    Attached Files Attached Files

  12. #12
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,863

    Re: N/A Question for Chart

    The thread on the other forum has gone down the how to use IFERROR() path. What I see in your sample file is a simple "dynamic named range" "dynamic chart" kind of question. There are multiple tutorials on the net. Here are the first two I pulled up when I put 'dynamic charts with dynamic named ranges excel" into my favorite internet search engine:
    http://www.criticaltosuccess.com/dyn...-named-ranges/
    https://www.techrepublic.com/blog/mi...arts-in-excel/

    The main difficulty is that, if you let the lookup functions return N/A, the count functions that tend to go into the OFFSET() function of the named range will not like the error values. It will probably be valuable to include the IFERROR() or IFNA() functions as described in the MrExcel thread to return a text string or something that the counting functions can ignore.

  13. #13
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    So I have to inherently change the formula in the cells regardless? There is no other way?

  14. #14
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,863

    Re: N/A Question for Chart

    I'm optimistic that it can be done. Your counting function in the OFFSET() function will just need to handle those error values. You might try the COUNT() function (COUNT(A2:A10)) and see if it has any trouble with the error values. If it doesn't then you can simply use that. If it does, find a different counting function that doesn't have trouble with the error values. FWIW, in my copy of Excel, the COUNT() function did just fine ignoring the N/A errors, so the COUNT() function might be good enough.

  15. #15
    Registered User
    Join Date
    02-06-2018
    Location
    Toronto, ON
    MS-Off Ver
    2013
    Posts
    8

    Re: N/A Question for Chart

    Got it, thanks for the response guys!

    Anyways here's the code that I'm working with right now:

    Option Explicit

    Sub Chart2_Click()
    Dim mySrs As Series
    Dim iPts As Long
    Dim bLabeled As Boolean
    If ActiveChart Is Nothing Then
    MsgBox "Select a chart and try again.", vbExclamation
    Else
    For Each mySrs In ActiveChart.SeriesCollection
    bLabeled = False
    With mySrs
    For iPts = .Points.Count To 1 Step -1
    If bLabeled Then ' series has already received valid label
    ' handle error if point isn't plotted
    On Error Resume Next
    ' remove existing label if it's not the last point
    mySrs.Points(iPts).HasDataLabel = False
    On Error GoTo 0
    Else ' series does not yet have valid label
    ' handle error if point isn't plotted
    On Error Resume Next
    ' remove existing label (linked labels otherwise resist reassignment)
    mySrs.Points(iPts).HasDataLabel = False

    ' test for 0 or #N/A (empty)
    If mySrs.Values(iPts) <> 0 Then
    If Not IsEmpty(mySrs.Values(iPts)) Then
    ' add label
    mySrs.Points(iPts).ApplyDataLabels _
    ShowSeriesName:=False, _
    ShowCategoryName:=False, ShowValue:=True, _
    AutoText:=True, LegendKey:=False
    bLabeled = (Err.Number = 0)
    End If
    End If

    ' 2010 no error if point doesn't exist: label applied, but it's blank
    If bLabeled Then bLabeled = (Len(mySrs.Points(iPts).DataLabel.Text) > 0)
    If Not bLabeled Then
    ' remove blank label
    mySrs.Points(iPts).HasDataLabel = False
    End If
    On Error GoTo 0
    End If
    Next
    End With
    Next
    End If
    End Sub

    I was able to resolve the issue of not having N/A values or 0 values appear on my chart. However, I wanted to make sure that only the last set of bars on the chart have values, so the last problem right now is that if one of the bars have an empty value, the second last bar will have value on them, which I don't want. I think there is an internal conflict within the code.. any help would be much appreciated!

  16. #16
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,863

    Re: N/A Question for Chart

    As you discovered earlier in this discussion, this forum can be strict about rules -- including the one about putting code in code tags. I recommend that you edit your last post to comply with the rule to avoid getting your topic locked.

    Until someone can have a closer look at it, the next thing I would do (it will almost certainly be the first thing I do when I can look at this) is to add a stop statement somewhere very early in the procedure to enter debug mode. That should allow me to step through the procedure and follow along each statement and change to see if it is doing what I expect it to do, and help identify where the internal conflict might be. In case you don't want to wait for someone else, you might try debugging this yourself and see what you learn. If you are unfamiliar with VBA's debugging tools: http://www.cpearson.com/excel/DebuggingVBA.aspx

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,444

    Re: N/A Question for Chart

    I gave you a link to our forum rules in post #7. It would appear that you STILL have not read them.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

+ 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. Urgent excel question! please help!
    By carissatan in forum Excel General
    Replies: 1
    Last Post: 10-28-2013, 10:35 AM
  2. Urgent web query question
    By spursrule68 in forum Excel General
    Replies: 2
    Last Post: 05-30-2012, 03:14 PM
  3. Second question, urgent!! (please:))) )
    By Sabrina19 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-14-2010, 06:06 PM
  4. Urgent question please help!!
    By nazatronic in forum Excel General
    Replies: 1
    Last Post: 03-01-2010, 10:15 PM
  5. Simple Question but need urgent help pls...
    By hendnov in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-12-2006, 09:15 AM
  6. urgent VBA question
    By dstyles782001 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-23-2006, 11:54 AM
  7. validation question, urgent pls help
    By daroc in forum Excel General
    Replies: 1
    Last Post: 01-23-2006, 06:20 PM
  8. [SOLVED] urgent question
    By excel date question in forum Excel General
    Replies: 1
    Last Post: 08-23-2005, 09:05 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