Run-Time Error: You must select a shape

L

Lee

I received a Microsoft Visual Basic Error at run-time which read "You must
select a shape". It was a warning prompt and it did not highlight a line of
code when I attempted to debug.

When the prompt is cleared the code continues to run. However, the problem
is that the code stops.

My Excel VBA code is performing a copy of worksheets from one workbook to
another.

After examining the workbook where the problem appeared to occur, I
discovered that a chart in the workbook had the focus or was left selected by
a user. There is also a pivot table on the same worksheet as the chart.

When I remove the focus from the chart, by selecting a cell on the
worksheet, the error is no longer produced.

Is this a bug, or designed behavior?
 
D

Don Guillett

you could make something like this as your first line.
ActiveSheet.ChartObjects("chart 1").Chart.Deselect
 

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