VBA: Get selected Range in a Worksheet where the Selection is a Chart

I have a Worksheet, with a Chart in it. If I select a range of cells, and then I select the Chart, then in the immediate window of the VBE

? TypeName(Selection)
ChartArea

So I cannot use Selection to get the selected Range, even if it is there (pressing Esc returns to the selected range of cells).

How can I retrieve that Range in VBA?

PS: I suspect the same Q&A applies to other Shapes.

Upvotes: 1

Views: 1652

Answers (1)

IAmDranged
IAmDranged

Reputation: 3020

You can use the RangeSelection property of the Window object (see this).

Upvotes: 3

Related Questions