Home » excel » excel – VBA: Get selected Range in a Worksheet where the Selection is a Chart

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

Posted by: admin May 14, 2020 Leave a comment

Questions:

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.

How to&Answers:

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