Excel VBA - to make it impossible for more than one cell to get selected

2Took

Board Regular
Joined
Jun 13, 2022
Messages
203
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm using below code, in BeforeDoubleClick, but for some reason, sometimes, multiple cells get selected down from a target cell, and obviously the subsequent code does not run - which is good.

But what code do I use to make it impossible for more than one cell to get selected?
So that only the first one Double Clicked on gets selected.

VBA Code:
If Target.Cells.count > 1 Then Exit Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
You can put your complete code.
In the double click event, only a double click on a cell is possible, unless you are double clicking on a merged cell.
Are you double clicking on a merged cell?
 
Upvote 0
You can put your complete code.
In the double click event, only a double click on a cell is possible, unless you are double clicking on a merged cell.
Are you double clicking on a merged cell?
Not a merged cell.
But what code do I use to make it impossible for more than one cell to get selected?
So that only the first one Double Clicked on gets selected.
 
Upvote 0
You can put your complete code.
👆


And an example from your sheet, use XL2BB tool.

Help us help you, put the complete macro, an example of the sheet or upload your file and explain what you are doing to cause the problem to occur.
And it also explains what the end goal is, maybe you need to run the code in multiple cells. I don't know.


You could upload a copy of your file to a free site such www.dropbox.com or google drive. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.

---
 
Upvote 0

Forum statistics

Threads
1,214,845
Messages
6,121,902
Members
449,053
Latest member
Guy Boot

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