De-select Active Cell from a selection with a VBA Macro
Originally published: 02/05/2019 06:52
Last version published: 20/03/2020 08:04
Publication number: ELQ-36975-2
View all versions & Certificate
certified

De-select Active Cell from a selection with a VBA Macro

De-select a cell from a collection of selected cells/ranges in an Excel worksheet

Description
This VBA macro enables you to de-select a single cell from a cluster of cells/ranges that you've cumulatively selected.

If you frequently work with Excel files, you might occasionally find yourself cumulatively selecting various cells/ranges (particularly non-contiguous ones) using Ctrl-Click/Ctrl-Click-and-drag, perhaps to apply the same format to the resulting selection. Once you've selected several, you might find you have erroneously clicked on a cell/range and want to remove it from the selection without having to face the frustration of starting all over again and wishing you'd done it in smaller chunks!

This tool allows you to do that. :-)

If necessary, you can move the active cell (without changing the selection) by using Tab (or Shift-Tab, in reverse). Take care not to inadvertently press any other keys, or you risk resetting the selection. Once the cursor is on the cell you want to de-select (i.e. it has become the Active cell), simply run the macro. Use Macro | Options to assign a shortcut key combination.

[There seems little point in dressing this code up in an .xls or .xlam file, so I've pasted it into a .docx file and you can just copy the text then paste it into your favourite place in your own VBA library (e.g. your Personal.xlb file). The VBA macro ‘DeselectCell’ will then be available to run.]

This Best Practice includes
One MSWord document containing text of VBA macro; one Excel screen illustration

Michael Martin offers you this Best Practice for free!

download for free

Add to bookmarks

Discuss

Further information

Handy VBA macro utility to save time

When several non-contiguous cells/ranges have been selected

Fewer than 3 cells selected


5.0 / 5 (1 votes)

please wait...