Clearing Focus or SendKeys ESC Equivalent

bs0d

Well-known Member
Joined
Dec 29, 2006
Messages
622
Through execution of my macro, I've had to activate a chart, and chart series - which leaves the focus on the chart (selected).

I'd like to reset the focus to nothing - the equivalent of hitting escape; but I can't use SendKeys "{ESC}" because it causes other problems.

How have others worked around this issue? I'd like to not select the chart, but it seems activating is required.

Thanks,
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Can't you just select a range to take the focus off the chart?

Edit: Just tested by manually selecting a series in a chart then doing this in the debug window:

Activecell.Select

Seems to work fine

Cheers

Dan
 
Last edited:
Upvote 0
So you're saying I should Select a range first, then do an active cell select?

Code:
Sheet1.Range("A1").Select
Activecell.Select

Following the logic of your signature, is there a way to prevent selecting here? Perhaps even avoid activating the chart when modifying the properties? Doing this "selects" it or brings to focus: (reference: http://www.mrexcel.com/forum/excel-...chart-fullseriescollection-optimize-code.html)
 
Upvote 0
So you're saying I should Select a range first, then do an active cell select?
No, unless you have specific cell that you want activated afterwards, what Dan is saying is if you execute ActiveCell.Select, focus will return to whatever cell was active just before you went to your chart.
 
Upvote 0
Ok, that didn't work for me.
Okay, I just tried what Dan posted and it did not work for me either (XL2003). I don't do much (virtually nothing) with charts, but I do note there is a Deselect method that may do what you want..

ActiveChart.Deselect
 
Upvote 0
Okay, I just tried what Dan posted and it did not work for me either (XL2003). I don't do much (virtually nothing) with charts, but I do note there is a Deselect method that may do what you want..

ActiveChart.Deselect

This is a strange situation. Your deselect code probably works, but it seems as if Excel (2013) has a focus lock on the chart. It won't even let me select a cell afterwards. So maybe other issues going on.

Thanks,
 
Upvote 0
update: So I was able to deselect the chart by using the activeCell.select method, but first had to select the tab as well. I guess I'll take 2 selects over an activechart at this point. Thanks for the feedback.
 
Upvote 0
Maybe do it in one line?

Code:
Sheets("MySheet").ActiveCell.select

Change MySheet to the Tab name.

And yes, Selecting is my pet hate but on a small number of occasions if it has to be done, it has to be done. I more hate it when people poll through a loop selecting cell after cell after cell to change a formula or something.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,580
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top