Selection type

M

Martin Stender

Hi all,

I have done a lot of VBA programming in PowerPoint, but I'm new to
Excel.

Now, want to manipulate charts, but I cannot figure out how to detect
if on or more charts on the active sheet are selected or not.

How do you discern between 'selection types' in Excel?

Thanks in advance! :)

Martin
 
C

Chip Pearson

Martin,

Use the TypeOf operator. E.g.,

If TypeOf Selection Is Excel.ChartArea Then
Debug.Print "Chart selected"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Hi Martin,

The following macro should give you some more ideas.
It is worth noting that with regards to charts, clicking on a commandbutton
to run such code can change which part of the chart is selected.


Regards,
Vic Eldridge


Sub WhatIsSelected()

MsgBox "TypeName = " & TypeName(Selection)

If TypeName(Selection) = "DrawingObjects" Then
Dim DrwObj As Object
For Each DrwObj In Selection
MsgBox TypeName(DrwObj)
Next
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top