Finding precise data points on series

XEVEN__

New Member
Joined
Aug 19, 2021
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I want to label a precise data point on my line chart. Every time I hover over the area I get the dates before or after instead of the exact date I want to label as the chart/lines are representing over twenty years of daily data you can imagine trying to zero in on a specific date/value. I am using excel 365. Is there another way to select the exact date I want to label instead of spending forever trying to hover over it and make it appear?
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi XEVEN_ Here is a vba solution. You will need to adjust the sheet name, chart number (if needed), seriescollection number and "YourDate" to suit. HTH. Dave
Code:
Sub test()
Dim Cnt As Long, YourDate As Date, Flag As Boolean
YourDate = Date '****** enter search date here
For Cnt = 1 To Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points.Count
If GetYLabel(1, Cnt) = YourDate Then
Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points(Cnt).DataLabel.Select
Flag = True
Exit For
End If
Next Cnt
If Flag Then
MsgBox "No date found"
End If
End Sub

Function GetYLabel(Isrs As Long, ipt As Long) As Double
' Isrs is series number, ipt is point number
Dim s As String, cht As Chart
Set cht = ActiveSheet.ChartObjects(1).Chart
s = GetYValue(cht, Isrs, ipt)
GetYLabel = s
End Function
ps. run the test sub to operate
 
Upvote 0
Whoops. Missed the edit. Dave
Code:
Sub test()
Dim Cnt As Long, YourDate As Date, Flag As Boolean
YourDate = Date '****** enter search date here
For Cnt = 1 To Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points.Count
If GetYLabel(1, Cnt) = YourDate Then
Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points(Cnt).DataLabel.Select
Flag = True
Exit For
End If
Next Cnt
If Not Flag Then
MsgBox "No date found"
End If
End Sub

Function GetYLabel(Isrs As Long, ipt As Long) As Double
' Isrs is series number, ipt is point number
Dim s As String, cht As Chart
Set cht = ActiveSheet.ChartObjects(1).Chart
s = GetYValue(cht, Isrs, ipt)
GetYLabel = s
End Function
 
Upvote 0
Solution
Whoops. Missed the edit. Dave
Code:
Sub test()
Dim Cnt As Long, YourDate As Date, Flag As Boolean
YourDate = Date '****** enter search date here
For Cnt = 1 To Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points.Count
If GetYLabel(1, Cnt) = YourDate Then
Sheets("Sheet1").ChartObjects(1).Chart.SeriesCollection(1).Points(Cnt).DataLabel.Select
Flag = True
Exit For
End If
Next Cnt
If Not Flag Then
MsgBox "No date found"
End If
End Sub

Function GetYLabel(Isrs As Long, ipt As Long) As Double
' Isrs is series number, ipt is point number
Dim s As String, cht As Chart
Set cht = ActiveSheet.ChartObjects(1).Chart
s = GetYValue(cht, Isrs, ipt)
GetYLabel = s
End Function
Thanks Dave! Sorry for the delayed response. I am only able to work on my charts periodically. I'm just learning this VBA. It is pretty cool so far. Very finicky but likely helpful of I cant figure it out.

Regards :)
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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