我有三列数据 x 值、y 值以及每组 xy 值的相应网页链接。是否可以将超链接添加到散点图,以便当我单击数据点或数据标签时,它会在浏览器中打开链接网页?
最佳答案
是的,这是可能的。但为此,您必须将图表放置在单独的图表表中。设置图表后,在 VBA 代码中使用图表事件 Chart_Select()。例如
Private Sub Chart_Select(ByVal ElementID As Long, _
ByVal Arg1 As Long, ByVal Arg2 As Long)
'Debug.Print "Element: " & ElementID
'Debug.Print " Arg 1: " & Arg1
'Debug.Print " Arg 2: " & Arg2
'~~> Please change as required.
If ElementID = 3 Then
Select Case Arg2
Case 1: ActiveWorkbook.FollowHyperlink "http:\\Google.Com", NewWindow:=True
Case 2: ActiveWorkbook.FollowHyperlink "http:\\Gmail.Com", NewWindow:=True
Case 3: ActiveWorkbook.FollowHyperlink "http:\\Msn.Com", NewWindow:=True
End Select
End If
End Sub
这应该可以帮助您入门。如果您有任何疑问,请告诉我。
关于excel - 将网页链接添加到 Excel 散点图上的每个数据点或数据标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9410618/