Solved

Show Last Values in  Excel Chart

Posted on 2013-01-14
6
503 Views
Last Modified: 2013-01-16
I would like to show the value of only the last point of all series in a line
 chart in excel.

I can do it manually, (click the point in the graph - data labels - show value).
Is it possible to do it automatically, so when I change the data source, the
chart will still show the value of the last point ?  Also,  I am not very familiar with VBA and attached you will find a sample spreadsheet.

I have used this link below but I was unsuccessful to get it working

http://peltiertech.com/Excel/Charts/LabelLastPoint.html
test.xlsx
0
Comment
Question by:jlloyd7940
  • 3
  • 2
6 Comments
 
LVL 22

Assisted Solution

by:Flyster
Flyster earned 150 total points
ID: 38776687
See formulas in Weekly Graphs worksheet cells H9:H10. It's reading the value from your data source and not the chart, but the values are the same.

Flyster
test.xlsx
0
 
LVL 18

Expert Comment

by:Curt Lindstrom
ID: 38776950
Try the attached file. It's based on the macros from peltiertech.com

You can see the macros in the modules MenuModule, modChartlabels and ThisWorkbook. These macros were copied from LabelLastPoint.zip in the from peltiertech.com web site

I modified the original macro in modChartlabels to this

 Option Explicit

Sub LastPointLabel()
    Dim mySrs As Series
    Dim nPts As Long
    Dim LastLabeled As Boolean
    If ActiveChart Is Nothing Then
        MsgBox "Please select a chart and try again.", vbExclamation
    Else
        For Each mySrs In ActiveChart.SeriesCollection
            LastLabeled = False
            nPts = mySrs.Points.Count
            For nPts = mySrs.Points.Count To 1 Step -1
                If Not mySrs.Values(nPts) = Empty Then
                    If LastLabeled = False Then
                        With mySrs
                            mySrs.Points(nPts).ApplyDataLabels _
                                    Type:=xlDataLabelsShowValue, _
                                    AutoText:=True, LegendKey:=False
                        End With
                        LastLabeled = True
                    Else
                        mySrs.Points(nPts).HasDataLabel = False
                    End If
                End If
            Next
        Next
    End If
End Sub

Open in new window


Please note that the Quota series in your original file had C3:C15 and C23 which I changed to C3:C15

Cheers,
Curt
Graph-test.xlsm
0
 
LVL 18

Accepted Solution

by:
Curt Lindstrom earned 350 total points
ID: 38776965
This version only has one macro which is the same modifed macro but without the modules MenuModule, modChartlabels and ThisWorkbook.

The macro is stored as a worksheet macro and activated when the Weekly Graphs sheet is opened.

Cheers,
Curt
Graph-test-Ver-2.xlsm
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jlloyd7940
ID: 38779951
Hello,

Thank you very much for all the responses and solutions are fantastic.
0
 
LVL 22

Expert Comment

by:Flyster
ID: 38781053
Thank you. I realize my solution didn't address specifically what you were looking for (Value from a chart), but it showed that there was a non-VBA approach!
0
 
LVL 18

Expert Comment

by:Curt Lindstrom
ID: 38781268
You're welcome! Let me know if you need anything to be clarified.

Cheers,
Curt
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now