I want to write a code that works whether if I select one or multiple charts in Excel.
Actually I use this code, but it fail when only one chart is seleted :
Dim obj As Object
'Check if any charts have been selected
If Not ActiveChart Is Nothing Then
MsgBox ("Select multiple charts")
Else
For Each obj In Selection
'If more than one chart selected
If TypeName(obj) = "ChartObject" Then
Call AnotherMacro(obj.Chart)
End If
Next
End If
I'm looking for a solution working into a unique Sub.
Thanks for your help
For Each, test ifSelectionis already aChartArea?Selectionwith Charts. It's too easy to accidentally select an element of a chart, instead of the whole thing.