Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Schlupp
 
Posts: n/a
Default HELP need index of the actual selected point

Hi,

I need help. I must get the index of a the currently selectd point in
the chart. I can't use the Mouseup event.
It will be better to determinate the x and y value from the actual
selected point but the index will also be good.

Please help!

thx
Jens

  #2   Report Post  
Jon Peltier
 
Posts: n/a
Default

You need to use an old-style XLM command for this, as Stephen Bullen
pointed out in his post 14-Jan-2001:

Sub WhichPoint()

Dim sPoint As String
Dim iSeries As Integer, iPoint As Integer

sPoint = ExecuteExcel4Macro("SELECTION()")

If sPoint Like "S*P*" Then
iSeries = Val(Mid$(sPoint, 2))
iPoint = Val(Mid$(sPoint, Len(iSeries) + 2))

MsgBox "Series " & iSeries & ", Point " & iPoint
Else
MsgBox "Please select a single data point."
End If

End Sub


- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Schlupp wrote:

Hi,

I need help. I must get the index of a the currently selectd point in
the chart. I can't use the Mouseup event.
It will be better to determinate the x and y value from the actual
selected point but the index will also be good.

Please help!

thx
Jens

  #3   Report Post  
Ed Ferrero
 
Posts: n/a
Default

Hi Jon,

There is also this old post from Eric Wells, if you do not like to use XLM.
<quote
'There is no easy way, as there is no name property for the Point
'object. Below you will find a function that will return a string
'corresponding to the point designation you see in the dropdown name box
'on a chart sheet (I've also included a macro that calls the function).
'The function relies on setting the MarkerStyle property of the point
'and then using a For-Next loop to identify the point index and then
'resetting the markerstyle. Note that there is no error checking to
'make sure that a point is actually selected, nor to check to see if the
'proper marketstyle is being used (if the entire series is formatted as
'xlstar, the funciton will fail - you'll have to select a different
'markerstyle).

Sub GetPoint()
Dim PointObject As Object
Set PointObject = Selection
MsgBox ReturnPoint(PointObject)
End Sub

Function ReturnPoint(PointObject As Object) As String
Dim PointMarkerStyle As Variant
Dim SeriesNum As Integer
Dim PointNum As Integer
Dim x As Integer
PointMarkerStyle = PointObject.MarkerStyle
PointObject.MarkerStyle = xlStar
With ActiveChart.SeriesCollection(PointObject.Parent.Na me)
SeriesNum = .PlotOrder
For x = 1 To .Points.Count
If .Points(x).MarkerStyle = xlStar Then
PointNum = x
Exit For
End If
Next
End With
PointObject.MarkerStyle = PointMarkerStyle
ReturnPoint = "S" & SeriesNum & "P" & PointNum
End Function

'-Eric Wells
'Microsoft
</quote

Ed Ferrero
http://edferrero.m6.net/



You need to use an old-style XLM command for this, as Stephen Bullen
pointed out in his post 14-Jan-2001:

Sub WhichPoint()

Dim sPoint As String
Dim iSeries As Integer, iPoint As Integer

sPoint = ExecuteExcel4Macro("SELECTION()")

If sPoint Like "S*P*" Then
iSeries = Val(Mid$(sPoint, 2))
iPoint = Val(Mid$(sPoint, Len(iSeries) + 2))

MsgBox "Series " & iSeries & ", Point " & iPoint
Else
MsgBox "Please select a single data point."
End If

End Sub


- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Schlupp wrote:

Hi,

I need help. I must get the index of a the currently selectd point in
the chart. I can't use the Mouseup event.
It will be better to determinate the x and y value from the actual
selected point but the index will also be good.

Please help!

thx
Jens



  #4   Report Post  
Jon Peltier
 
Posts: n/a
Default

Hi Ed -

I also had a version of the Eric Wells approach, with temporary point
formatting, but didn't suggest it because I'm not comfortable with it.
My problem, alluded to in Eric's post, is that if my series formatting
is already xlStar, I'll never find the selected point. This can be fixed
using another layer of coding, but it was already longer and more
convoluted than the XLM command. And the XLM command detects whether a
point is selected (If sPoint Like "S*P*" Then).

XLM's not so bad, and often (like this) it's the easiest way, or the
only way, to get something done. Print Setup is another: the VBA way
takes minutes, while XLM is nearly instantaneous.

Many times people do things the hard way, because they have a
preconceived notion they force their approach to conform to. Like it's
bad to add columns for intermediate calculations or for conditioned data
for charting. In fact, it's easier to do it this way, and you can find
your mistakes more easily. And you can put the extra range out of sight
of the casual observer.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Ed Ferrero wrote:
Hi Jon,

There is also this old post from Eric Wells, if you do not like to use XLM.
<quote
'There is no easy way, as there is no name property for the Point
'object. Below you will find a function that will return a string
'corresponding to the point designation you see in the dropdown name box
'on a chart sheet (I've also included a macro that calls the function).
'The function relies on setting the MarkerStyle property of the point
'and then using a For-Next loop to identify the point index and then
'resetting the markerstyle. Note that there is no error checking to
'make sure that a point is actually selected, nor to check to see if the
'proper marketstyle is being used (if the entire series is formatted as
'xlstar, the funciton will fail - you'll have to select a different
'markerstyle).

Sub GetPoint()
Dim PointObject As Object
Set PointObject = Selection
MsgBox ReturnPoint(PointObject)
End Sub

Function ReturnPoint(PointObject As Object) As String
Dim PointMarkerStyle As Variant
Dim SeriesNum As Integer
Dim PointNum As Integer
Dim x As Integer
PointMarkerStyle = PointObject.MarkerStyle
PointObject.MarkerStyle = xlStar
With ActiveChart.SeriesCollection(PointObject.Parent.Na me)
SeriesNum = .PlotOrder
For x = 1 To .Points.Count
If .Points(x).MarkerStyle = xlStar Then
PointNum = x
Exit For
End If
Next
End With
PointObject.MarkerStyle = PointMarkerStyle
ReturnPoint = "S" & SeriesNum & "P" & PointNum
End Function

'-Eric Wells
'Microsoft
</quote

Ed Ferrero
http://edferrero.m6.net/




You need to use an old-style XLM command for this, as Stephen Bullen
pointed out in his post 14-Jan-2001:

Sub WhichPoint()

Dim sPoint As String
Dim iSeries As Integer, iPoint As Integer

sPoint = ExecuteExcel4Macro("SELECTION()")

If sPoint Like "S*P*" Then
iSeries = Val(Mid$(sPoint, 2))
iPoint = Val(Mid$(sPoint, Len(iSeries) + 2))

MsgBox "Series " & iSeries & ", Point " & iPoint
Else
MsgBox "Please select a single data point."
End If

End Sub


- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


Schlupp wrote:


Hi,

I need help. I must get the index of a the currently selectd point in
the chart. I can't use the Mouseup event.
It will be better to determinate the x and y value from the actual
selected point but the index will also be good.

Please help!

thx
Jens




  #5   Report Post  
Schlupp
 
Posts: n/a
Default

Thats what I needed. Thankyou very much.

Jens



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i make it so that when a sheat is selected either via link or tab, that xlLastCell is selected. the last on the sheet. Daniel Excel Worksheet Functions 1 July 12th 05 01:30 AM
cell color index comparison MINAL ZUNKE New Users to Excel 1 June 30th 05 07:11 AM
Perform oiperations relative to initial selected cell scratching my head Excel Discussion (Misc queries) 1 May 30th 05 05:42 PM
Min formula not returning value from Index ExcelMonkey Excel Worksheet Functions 3 January 29th 05 01:47 AM
index to a range of cells Frank Kabel Excel Worksheet Functions 0 October 27th 04 05:39 PM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"