Data label only to the last data point

sharshra

Active Member
Joined
Mar 20, 2013
Messages
352
Office Version
  1. 365
I want to display the data point only at the end of line graph. At present, I´m using few calculations in a separate column to find the value of the last cell in a column. Are there any better ways to achieve the same without having an additional column just find out the last cell?

1723207087938.png
 

Attachments

  • 1723206959638.png
    1723206959638.png
    3.3 KB · Views: 8

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try the following code...

VBA Code:
Sub test()

    Dim targetChart As Chart
    Dim currentSeries As Series
    Dim lastPoint As Point
    
    Set targetChart = ThisWorkbook.Worksheets("Sheet1").ChartObjects("Chart 1").Chart 'change the sheet and chart names accordingly
    
    For Each currentSeries In targetChart.SeriesCollection
        With currentSeries
            Set lastPoint = .Points(.Points.Count)
            lastPoint.ApplyDataLabels
            lastPoint.DataLabel.Position = xlLabelPositionAbove
        End With
    Next currentSeries
    
End Sub

Hope this helps!
 
Upvote 0
Thanks, @Domenic. This VBA code is very useful (y)

In this case, I´m looking for any solution thru excel formula or setting, without using VBA. Are there any options?
 
Upvote 0
@felixstraube, the data points can vary. It will not remain the same but can grow.

@Domenic, Thanks for sharing the link. It suggests about doing it manually. I´m looking for having something without manual intervention. At present, I have done this, but only after adding an additional column just to get this done. Looking for something if the same result can be achieved without the additional column.
 
Upvote 0
In that case try this:

My example works with these 2 columns of data:

LineChart.xlsx
AB
1
2Data Col 1Data Col 2
31
42
554
665
7107
8118
9129
1013
11
Sheet3


Then create these named ranges:

Name: "Serie1"
Excel Formula:
=LET( d,OFFSET(Sheet3!$A$3,0,0,MAX(ROW(Sheet3!$A$3:$A$100)*(Sheet3!$A$3:$A$100<>""))-ROW(Sheet3!$A$2)), IF(d="",NA(),d) )

Name: "Serie2"
Excel Formula:
=LET( d,OFFSET(Sheet3!$B$3,0,0,MAX(ROW(Sheet3!$B$3:$B$100)*(Sheet3!$B$3:$B$100<>""))-ROW(Sheet3!$A$2)), IF(d="",NA(),d) )

Name: "Serie1_Last"
Excel Formula:
=VSTACK(DROP(EXPAND("", ROWS(Serie1),,NA()),1), TAKE(Serie1, -1))

Name: "Serie2_Last"
Excel Formula:
=VSTACK(DROP(EXPAND("", ROWS(Serie2),,NA()),1), TAKE(Serie2, -1))

Then you create a line chart, and define the data as follows:

1723218801072.png


Then in the Chart format you set no marker for the first two series, and the marker of your liking for series 3 and 4.

So for example you would get:
1723219060500.png


And after adding some values:

1723219046677.png



Here is a working file for you to try:

LineChart.zip

Let me know if this works for you.
 
Upvote 1
Solution

Forum statistics

Threads
1,221,526
Messages
6,160,340
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top