Can I prevent users selecting multiple cells?

A

Angus Comber

Hello

If a user ttempts to select multiple cells or clicks on the top left to
select all rows I want to just select the top left cell in the selection -
overriding Excels usual behaviour. Can I do this? Please let me know how?

Angus Comber
(e-mail address removed)
 
H

Harald Staff

Hi Angus

A macro can do everything. So assuming macros are enabled, running, healthy, well written
and adored. Rightclick the sheet tab, choose "View code", paste this in:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Target(1).Select
End Sub

.... but it is not a nice thing to do. Nothing "overriding" is.
 
C

Chip Pearson

Just to keep the macro code "healthy, well-written, and adored", you might
want to disable events in the macro. E.g.,

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = False
Target(1).Select
Application.EnableEvents = True
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 
H

Harald Staff

Chip Pearson said:
Just to keep the macro code "healthy, well-written, and adored", you might
want to disable events in the macro.

Ok, I want that :)
 
M

mcpheat

Try menu
tools/options/
and uncheck "row and column headers" under the view tab

Tony.
 

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